From 0dc4addb9111a1587ba9c08594a0f087905a572a Mon Sep 17 00:00:00 2001 From: Luis Araneda Date: Thu, 5 Jul 2018 16:55:31 -0400 Subject: [PATCH 1/9] kconfig: Avoid format overflow warning from GCC 8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cherry-pick kernel commit 2ae89c7 (2018-06-05) to avoid warnings when compiling with GCC 8.1 In file included from scripts/kconfig/zconf.tab.c:2486: scripts/kconfig/confdata.c: In function ‘conf_write’: scripts/kconfig/confdata.c:771:22: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=] sprintf(newname, "%s%s", dirname, basename); ^~ scripts/kconfig/confdata.c:771:19: note: assuming directive output of 7 bytes sprintf(newname, "%s%s", dirname, basename); ^~~~~~ scripts/kconfig/confdata.c:771:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097 sprintf(newname, "%s%s", dirname, basename); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ scripts/kconfig/confdata.c:774:23: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=] sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); ^~~~~~~~~~~ scripts/kconfig/confdata.c:774:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097 sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Luis Araneda Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index e4cbb87d76..a04bb26304 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -743,7 +743,7 @@ int conf_write(const char *name) struct menu *menu; const char *basename; const char *str; - char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; + char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8]; char *env; dirname[0] = 0; From 4a610fada193057c97c1b23016ef119f98459b22 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 10:13:23 +0900 Subject: [PATCH 2/9] mtd: nand: denali: correct buffer alignment for DMA transfer The NAND framework makes sure to pass in the buffer with at least chip->buf_align alignment. Currently, the Denali NAND driver only requests 16 byte alignment. This causes unaligned cache operations for the DMA transfer. [Error Example] => nand read 81000010 0 1000 NAND read: device 0 offset 0x0, size 0x1000 CACHE: Misaligned operation at range [81000010, 81001010] CACHE: Misaligned operation at range [81000010, 81001010] CACHE: Misaligned operation at range [81000010, 81001010] CACHE: Misaligned operation at range [81000010, 81001010] 4096 bytes read: OK Reported-by: Marek Vasut Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/denali.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 6266c8aa92..7302c37003 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1270,7 +1270,7 @@ int denali_init(struct denali_nand_info *denali) denali->dma_avail = 1; if (denali->dma_avail) { - chip->buf_align = 16; + chip->buf_align = ARCH_DMA_MINALIGN; if (denali->caps & DENALI_CAP_DMA_64BIT) denali->setup_dma = denali_setup_dma64; else From 5f4e32d058755a93a9cc43ea9998195a3ef13aa2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:22 +0900 Subject: [PATCH 3/9] fdt_support: make fdt_fixup_mtdparts() prototype more specific The second argument of fdt_fixup_mtdparts() is an opaque pointer, 'void *node_info', hence callers can pass any pointer. Obviously, fdt_fixup_mtdparts() expects 'struct node_info *' otherwise, it crashes run-time. Change the prototype so that it is compile-time checked. Also, add 'const' qualifier to it so that callers can constify the struct node_info arrays. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/fdt_support.c | 13 +++++++------ include/fdt_support.h | 11 ++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 812eca8173..3b31f3d7d5 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -893,9 +893,9 @@ err_prop: * * fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); */ -void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) +void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, + int node_info_size) { - struct node_info *ni = node_info; struct mtd_device *dev; int i, idx; int noff; @@ -905,12 +905,13 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) for (i = 0; i < node_info_size; i++) { idx = 0; - noff = fdt_node_offset_by_compatible(blob, -1, ni[i].compat); + noff = fdt_node_offset_by_compatible(blob, -1, + node_info[i].compat); while (noff != -FDT_ERR_NOTFOUND) { debug("%s: %s, mtd dev type %d\n", fdt_get_name(blob, noff, 0), - ni[i].compat, ni[i].type); - dev = device_find(ni[i].type, idx++); + node_info[i].compat, node_info[i].type); + dev = device_find(node_info[i].type, idx++); if (dev) { if (fdt_node_set_part_info(blob, noff, dev)) return; /* return on error */ @@ -918,7 +919,7 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) /* Jump to next flash node */ noff = fdt_node_offset_by_compatible(blob, noff, - ni[i].compat); + node_info[i].compat); } } } diff --git a/include/fdt_support.h b/include/fdt_support.h index a9a0078af6..27fe564f0b 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -205,11 +205,16 @@ int fdt_increase_size(void *fdt, int add_len); int fdt_fixup_nor_flash_size(void *blob); +struct node_info; #if defined(CONFIG_FDT_FIXUP_PARTITIONS) -void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size); +void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info, + int node_info_size); #else -static inline void fdt_fixup_mtdparts(void *fdt, void *node_info, - int node_info_size) {} +static inline void fdt_fixup_mtdparts(void *fdt, + const struct node_info *node_info, + int node_info_size) +{ +} #endif void fdt_del_node_and_alias(void *blob, const char *alias); From b35fb6ace67202b6f668f744f958a5ef66665151 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:23 +0900 Subject: [PATCH 4/9] board: constify struct node_info array Add 'const' (also 'static' in some places) to struct node_info arrays to save memory footprint. Signed-off-by: Masahiro Yamada --- board/CarMediaLab/flea3/flea3.c | 2 +- board/compulab/cm_fx6/cm_fx6.c | 2 +- board/freescale/bsc9131rdb/bsc9131rdb.c | 2 +- board/freescale/bsc9132qds/bsc9132qds.c | 2 +- board/gateworks/gw_ventana/gw_ventana.c | 2 +- board/isee/igep003x/board.c | 2 +- board/isee/igep00x0/igep00x0.c | 2 +- board/toradex/colibri_imx7/colibri_imx7.c | 2 +- board/toradex/colibri_vf/colibri_vf.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/board/CarMediaLab/flea3/flea3.c b/board/CarMediaLab/flea3/flea3.c index c0f33b806e..9eec1b7838 100644 --- a/board/CarMediaLab/flea3/flea3.c +++ b/board/CarMediaLab/flea3/flea3.c @@ -205,7 +205,7 @@ u32 get_board_rev(void) */ int ft_board_setup(void *blob, bd_t *bd) { - struct node_info nodes[] = { + static const struct node_info nodes[] = { { "physmap-flash.0", MTD_DEV_TYPE_NOR, }, /* NOR flash */ { "mxc_nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */ }; diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c index c114cdccbb..d42f57d4b7 100644 --- a/board/compulab/cm_fx6/cm_fx6.c +++ b/board/compulab/cm_fx6/cm_fx6.c @@ -519,7 +519,7 @@ int cm_fx6_setup_ecspi(void) { return 0; } #ifdef CONFIG_OF_BOARD_SETUP #define USDHC3_PATH "/soc/aips-bus@02100000/usdhc@02198000/" -struct node_info nodes[] = { +static const struct node_info nodes[] = { /* * Both entries target the same flash chip. The st,m25p compatible * is used in the vendor device trees, while upstream uses (the diff --git a/board/freescale/bsc9131rdb/bsc9131rdb.c b/board/freescale/bsc9131rdb/bsc9131rdb.c index 367152fa5f..9d9c83f716 100644 --- a/board/freescale/bsc9131rdb/bsc9131rdb.c +++ b/board/freescale/bsc9131rdb/bsc9131rdb.c @@ -53,7 +53,7 @@ int checkboard(void) #if defined(CONFIG_OF_BOARD_SETUP) #ifdef CONFIG_FDT_FIXUP_PARTITIONS -struct node_info nodes[] = { +static const struct node_info nodes[] = { { "fsl,ifc-nand", MTD_DEV_TYPE_NAND, }, }; #endif diff --git a/board/freescale/bsc9132qds/bsc9132qds.c b/board/freescale/bsc9132qds/bsc9132qds.c index 6885668ff9..36a55285e8 100644 --- a/board/freescale/bsc9132qds/bsc9132qds.c +++ b/board/freescale/bsc9132qds/bsc9132qds.c @@ -357,7 +357,7 @@ void fdt_del_node_compat(void *blob, const char *compatible) #if defined(CONFIG_OF_BOARD_SETUP) #ifdef CONFIG_FDT_FIXUP_PARTITIONS -struct node_info nodes[] = { +static const struct node_info nodes[] = { { "cfi-flash", MTD_DEV_TYPE_NOR, }, { "fsl,ifc-nand", MTD_DEV_TYPE_NAND, }, }; diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index b86924ebe2..c4ec97435f 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -1114,7 +1114,7 @@ int ft_board_setup(void *blob, bd_t *bd) { struct ventana_board_info *info = &ventana_info; struct ventana_eeprom_config *cfg; - struct node_info nodes[] = { + static const struct node_info nodes[] = { { "sst,w25q256", MTD_DEV_TYPE_NOR, }, /* SPI flash */ { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */ }; diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c index cc55bcc81a..965a009a9f 100644 --- a/board/isee/igep003x/board.c +++ b/board/isee/igep003x/board.c @@ -211,7 +211,7 @@ int board_late_init(void) int ft_board_setup(void *blob, bd_t *bd) { #ifdef CONFIG_FDT_FIXUP_PARTITIONS - static struct node_info nodes[] = { + static const struct node_info nodes[] = { { "ti,omap2-nand", MTD_DEV_TYPE_NAND, }, }; diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c index 45a414c153..367af82d4a 100644 --- a/board/isee/igep00x0/igep00x0.c +++ b/board/isee/igep00x0/igep00x0.c @@ -157,7 +157,7 @@ static int ft_enable_by_compatible(void *blob, char *compat, int enable) int ft_board_setup(void *blob, bd_t *bd) { #ifdef CONFIG_FDT_FIXUP_PARTITIONS - static struct node_info nodes[] = { + static const struct node_info nodes[] = { { "ti,omap2-nand", MTD_DEV_TYPE_NAND, }, { "ti,omap2-onenand", MTD_DEV_TYPE_ONENAND, }, }; diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c index f9f488db1c..2210095d7a 100644 --- a/board/toradex/colibri_imx7/colibri_imx7.c +++ b/board/toradex/colibri_imx7/colibri_imx7.c @@ -389,7 +389,7 @@ int checkboard(void) int ft_board_setup(void *blob, bd_t *bd) { #if defined(CONFIG_FDT_FIXUP_PARTITIONS) - static struct node_info nodes[] = { + static const struct node_info nodes[] = { { "fsl,imx7d-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */ { "fsl,imx6q-gpmi-nand", MTD_DEV_TYPE_NAND, }, }; diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c index 83c3503007..4db1757469 100644 --- a/board/toradex/colibri_vf/colibri_vf.c +++ b/board/toradex/colibri_vf/colibri_vf.c @@ -580,7 +580,7 @@ int ft_board_setup(void *blob, bd_t *bd) { int ret = 0; #ifdef CONFIG_FDT_FIXUP_PARTITIONS - static struct node_info nodes[] = { + static const struct node_info nodes[] = { { "fsl,vf610-nfc", MTD_DEV_TYPE_NAND, }, /* NAND flash */ }; From e9687153027f4e1adbe17d6bd9da381c23235061 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:24 +0900 Subject: [PATCH 5/9] ARM: uniphier: clean-up ft_board_setup() The 'bd' is passed in ft_board_setup() as the second argument. Replace 'gd->bd' with 'bd'. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/dram_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index 2eb4836256..8aa3f81cfc 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -279,11 +279,11 @@ int ft_board_setup(void *fdt, bd_t *bd) if (uniphier_get_soc_id() != UNIPHIER_LD20_ID) return 0; - for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) { - if (!gd->bd->bi_dram[i].size) + for (i = 0; i < ARRAY_SIZE(bd->bi_dram); i++) { + if (!bd->bi_dram[i].size) continue; - rsv_addr = gd->bd->bi_dram[i].start + gd->bd->bi_dram[i].size; + rsv_addr = bd->bi_dram[i].start + bd->bi_dram[i].size; rsv_addr -= rsv_size; ret = fdt_add_mem_rsv(fdt, rsv_addr, rsv_size); From 65fce7630127cfc71c5d415bca8e23106b5b0763 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:25 +0900 Subject: [PATCH 6/9] ARM: uniphier: split ft_board_setup() out to a separate file Prepare to add more fdt fixup code. Signed-off-by: Masahiro Yamada --- arch/arm/Kconfig | 1 + arch/arm/mach-uniphier/Kconfig | 1 - arch/arm/mach-uniphier/Makefile | 1 + arch/arm/mach-uniphier/dram_init.c | 35 ------------------- arch/arm/mach-uniphier/fdt-fixup.c | 56 ++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 36 deletions(-) create mode 100644 arch/arm/mach-uniphier/fdt-fixup.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 376851ef7a..dc9e24dc58 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1223,6 +1223,7 @@ config ARCH_UNIPHIER select DM_RESET select DM_SERIAL select DM_USB + select OF_BOARD_SETUP select OF_CONTROL select OF_LIBFDT select PINCTRL diff --git a/arch/arm/mach-uniphier/Kconfig b/arch/arm/mach-uniphier/Kconfig index 91bea776e6..c199374086 100644 --- a/arch/arm/mach-uniphier/Kconfig +++ b/arch/arm/mach-uniphier/Kconfig @@ -68,7 +68,6 @@ config ARCH_UNIPHIER_LD11 config ARCH_UNIPHIER_LD20 bool "Enable UniPhier LD20 SoC support" depends on ARCH_UNIPHIER_V8_MULTI - select OF_BOARD_SETUP default y config ARCH_UNIPHIER_PXS3 diff --git a/arch/arm/mach-uniphier/Makefile b/arch/arm/mach-uniphier/Makefile index 269c51b853..d0c39d4273 100644 --- a/arch/arm/mach-uniphier/Makefile +++ b/arch/arm/mach-uniphier/Makefile @@ -21,6 +21,7 @@ endif obj-$(CONFIG_MICRO_SUPPORT_CARD) += sbc/ micro-support-card.o obj-y += pinctrl-glue.o obj-$(CONFIG_MMC) += mmc-first-dev.o +obj-y += fdt-fixup.o endif diff --git a/arch/arm/mach-uniphier/dram_init.c b/arch/arm/mach-uniphier/dram_init.c index 8aa3f81cfc..7e7c1d98db 100644 --- a/arch/arm/mach-uniphier/dram_init.c +++ b/arch/arm/mach-uniphier/dram_init.c @@ -6,8 +6,6 @@ */ #include -#include -#include #include #include #include @@ -264,36 +262,3 @@ int dram_init_banksize(void) return 0; } - -#ifdef CONFIG_OF_BOARD_SETUP -/* - * The DRAM PHY requires 64 byte scratch area in each DRAM channel - * for its dynamic PHY training feature. - */ -int ft_board_setup(void *fdt, bd_t *bd) -{ - unsigned long rsv_addr; - const unsigned long rsv_size = 64; - int i, ret; - - if (uniphier_get_soc_id() != UNIPHIER_LD20_ID) - return 0; - - for (i = 0; i < ARRAY_SIZE(bd->bi_dram); i++) { - if (!bd->bi_dram[i].size) - continue; - - rsv_addr = bd->bi_dram[i].start + bd->bi_dram[i].size; - rsv_addr -= rsv_size; - - ret = fdt_add_mem_rsv(fdt, rsv_addr, rsv_size); - if (ret) - return -ENOSPC; - - pr_notice(" Reserved memory region for DRAM PHY training: addr=%lx size=%lx\n", - rsv_addr, rsv_size); - } - - return 0; -} -#endif diff --git a/arch/arm/mach-uniphier/fdt-fixup.c b/arch/arm/mach-uniphier/fdt-fixup.c new file mode 100644 index 0000000000..022e44216e --- /dev/null +++ b/arch/arm/mach-uniphier/fdt-fixup.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016-2018 Socionext Inc. + * Author: Masahiro Yamada + */ + +#include +#include +#include +#include +#include + +#include "soc-info.h" + +/* + * The DRAM PHY requires 64 byte scratch area in each DRAM channel + * for its dynamic PHY training feature. + */ +static int uniphier_ld20_fdt_mem_rsv(void *fdt, bd_t *bd) +{ + unsigned long rsv_addr; + const unsigned long rsv_size = 64; + int i, ret; + + if (!IS_ENABLED(CONFIG_ARCH_UNIPHIER_LD20) || + uniphier_get_soc_id() != UNIPHIER_LD20_ID) + return 0; + + for (i = 0; i < ARRAY_SIZE(bd->bi_dram); i++) { + if (!bd->bi_dram[i].size) + continue; + + rsv_addr = bd->bi_dram[i].start + bd->bi_dram[i].size; + rsv_addr -= rsv_size; + + ret = fdt_add_mem_rsv(fdt, rsv_addr, rsv_size); + if (ret) + return -ENOSPC; + + pr_notice(" Reserved memory region for DRAM PHY training: addr=%lx size=%lx\n", + rsv_addr, rsv_size); + } + + return 0; +} + +int ft_board_setup(void *fdt, bd_t *bd) +{ + int ret; + + ret = uniphier_ld20_fdt_mem_rsv(fdt, bd); + if (ret) + return ret; + + return 0; +} From bb04d2ec4d1fc1924b491c074ccfdad633167cc7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:26 +0900 Subject: [PATCH 7/9] ARM: uniphier: support fdt_fixup_mtdparts Propagate the "mtdparts" environment variable to the DT passed in to OS. Signed-off-by: Masahiro Yamada --- arch/arm/mach-uniphier/fdt-fixup.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/mach-uniphier/fdt-fixup.c b/arch/arm/mach-uniphier/fdt-fixup.c index 022e44216e..6f3c29d8c0 100644 --- a/arch/arm/mach-uniphier/fdt-fixup.c +++ b/arch/arm/mach-uniphier/fdt-fixup.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include @@ -46,8 +48,14 @@ static int uniphier_ld20_fdt_mem_rsv(void *fdt, bd_t *bd) int ft_board_setup(void *fdt, bd_t *bd) { + static const struct node_info nodes[] = { + { "socionext,uniphier-denali-nand-v5a", MTD_DEV_TYPE_NAND }, + { "socionext,uniphier-denali-nand-v5b", MTD_DEV_TYPE_NAND }, + }; int ret; + fdt_fixup_mtdparts(fdt, nodes, ARRAY_SIZE(nodes)); + ret = uniphier_ld20_fdt_mem_rsv(fdt, bd); if (ret) return ret; From ae7a0d5b662bbffc2fb8cb9883a71a8db43df651 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 19 Jul 2018 16:28:27 +0900 Subject: [PATCH 8/9] ARM: uniphier: enable MTD partition and UBI Enable "mtdparts" and "ubi" commands for uniphier_v8_defconfig to use UBI on NAND devices. Enable only "mtdparts" for uniphier_{v7,ld4_sld8}_defconfig because enabling UBI would increase 170KB, which would be memory footprint problem. Signed-off-by: Masahiro Yamada --- configs/uniphier_ld4_sld8_defconfig | 6 +++++- configs/uniphier_v7_defconfig | 6 +++++- configs/uniphier_v8_defconfig | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/configs/uniphier_ld4_sld8_defconfig b/configs/uniphier_ld4_sld8_defconfig index 610035a8af..7dfc88fdbb 100644 --- a/configs/uniphier_ld4_sld8_defconfig +++ b/configs/uniphier_ld4_sld8_defconfig @@ -31,6 +31,9 @@ CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=uniphier-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=uniphier-nand.0:1m(firmware),-(UBI)" # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_NET_RANDOM_ETHADDR=y @@ -39,7 +42,7 @@ CONFIG_MISC=y CONFIG_I2C_EEPROM=y CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10 CONFIG_MMC_UNIPHIER=y -CONFIG_MTD_DEVICE=y +CONFIG_MTD_PARTITIONS=y CONFIG_NAND=y CONFIG_NAND_DENALI_DT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 @@ -53,3 +56,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_STORAGE=y CONFIG_PANIC_HANG=y +CONFIG_FDT_FIXUP_PARTITIONS=y diff --git a/configs/uniphier_v7_defconfig b/configs/uniphier_v7_defconfig index 8dae587e01..ccd80c00f8 100644 --- a/configs/uniphier_v7_defconfig +++ b/configs/uniphier_v7_defconfig @@ -30,6 +30,9 @@ CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +CONFIG_CMD_MTDPARTS=y +CONFIG_MTDIDS_DEFAULT="nand0=uniphier-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=uniphier-nand.0:1m(firmware),-(UBI)" # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_NET_RANDOM_ETHADDR=y @@ -38,7 +41,7 @@ CONFIG_MISC=y CONFIG_I2C_EEPROM=y CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=10 CONFIG_MMC_UNIPHIER=y -CONFIG_MTD_DEVICE=y +CONFIG_MTD_PARTITIONS=y CONFIG_NAND=y CONFIG_NAND_DENALI_DT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 @@ -54,3 +57,4 @@ CONFIG_USB_DWC3=y CONFIG_USB_DWC3_UNIPHIER=y CONFIG_USB_STORAGE=y CONFIG_PANIC_HANG=y +CONFIG_FDT_FIXUP_PARTITIONS=y diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig index 235d1f5222..67ebde7a10 100644 --- a/configs/uniphier_v8_defconfig +++ b/configs/uniphier_v8_defconfig @@ -26,6 +26,9 @@ CONFIG_CMD_TIME=y # CONFIG_CMD_MISC is not set CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +CONFIG_MTDIDS_DEFAULT="nand0=uniphier-nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=uniphier-nand.0:1m(firmware),-(UBI)" +CONFIG_CMD_UBI=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_GPIO_UNIPHIER=y CONFIG_MISC=y @@ -36,7 +39,6 @@ CONFIG_MMC_UNIPHIER=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_CADENCE=y -CONFIG_MTD_DEVICE=y CONFIG_NAND=y CONFIG_NAND_DENALI_DT=y CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8 @@ -54,3 +56,4 @@ CONFIG_USB_DWC3=y CONFIG_USB_DWC3_UNIPHIER=y CONFIG_USB_STORAGE=y CONFIG_PANIC_HANG=y +CONFIG_FDT_FIXUP_PARTITIONS=y From 7ef5b1e7ed040683ff551f0234c471ce0d76828c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 20 Jul 2018 21:47:18 +0900 Subject: [PATCH 9/9] ARM: uniphier: enable distro boot Switch to the distro boot for UniPhier platform. - Remove the environment vairalbes used to load images from raw block devices. - Keep the command to download images via tftp. This will be useful to boot the kernel when no valid kernel image is ready yet in the file system. - Use root.cpio.gz instead of root.cpio.uboot because we always know the file size of the init ramdisk; it is loaded via either a file system or network. - Rename fit_addr_r to kernel_addr_r, which the distro command checks to get the load address of FIT image. Signed-off-by: Masahiro Yamada --- arch/arm/Kconfig | 1 + arch/arm/mach-uniphier/board_late_init.c | 8 +-- doc/README.uniphier | 55 ++++++++++++++++ include/configs/uniphier.h | 84 +++++++++++------------- 4 files changed, 100 insertions(+), 48 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index dc9e24dc58..3d9b9dc83f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1234,6 +1234,7 @@ config ARCH_UNIPHIER select SPL_OF_CONTROL if SPL select SPL_PINCTRL if SPL select SUPPORT_SPL + imply DISTRO_DEFAULTS imply FAT_WRITE help Support for UniPhier SoC family developed by Socionext Inc. diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c index 6a995728d4..8ffb9a8d3c 100644 --- a/arch/arm/mach-uniphier/board_late_init.c +++ b/arch/arm/mach-uniphier/board_late_init.c @@ -66,20 +66,20 @@ int board_late_init(void) switch (uniphier_boot_device_raw()) { case BOOT_DEVICE_MMC1: printf("eMMC Boot"); - env_set("bootmode", "emmcboot"); + env_set("bootcmd", "run bootcmd_mmc0; run distro_bootcmd"); break; case BOOT_DEVICE_NAND: printf("NAND Boot"); - env_set("bootmode", "nandboot"); + env_set("bootcmd", "run bootcmd_ubifs0; run distro_bootcmd"); nand_denali_wp_disable(); break; case BOOT_DEVICE_NOR: printf("NOR Boot"); - env_set("bootmode", "norboot"); + env_set("bootcmd", "run tftpboot; run distro_bootcmd"); break; case BOOT_DEVICE_USB: printf("USB Boot"); - env_set("bootmode", "usbboot"); + env_set("bootcmd", "run bootcmd_usb0; run distro_bootcmd"); break; default: printf("Unknown"); diff --git a/doc/README.uniphier b/doc/README.uniphier index 990806ab79..badfacd66a 100644 --- a/doc/README.uniphier +++ b/doc/README.uniphier @@ -332,6 +332,61 @@ for kernel, DTB, and Init ramdisk. If they are not displayed, the Verified Boot is not working. +Deployment for Distro Boot +-------------------------- + +UniPhier SoC family boot the kernel in a generic manner as described in +doc/README.distro . + +To boot the kernel, you need to deploy necesssary components to a file +system on one of your block devices (eMMC, NAND, USB drive, etc.). + +The components depend on the kernel image format. + +[1] Bare images + + - kernel + - init ramdisk + - device tree blob + - boot configuration file (extlinux.conf) + +Here is an exmple of the configuration file. + +-------------------->8-------------------- +menu title UniPhier Boot Options. + +timeout 50 +default UniPhier + +label UniPhier + kernel ../Image + initrd ../rootfs.cpio.gz + fdtdir .. +-------------------->8-------------------- + +Then, write 'Image', 'rootfs.cpio.gz', 'uniphier-ld20-ref.dtb' (DTB depends on +your board), and 'extlinux/extlinux.conf' to the file system. + +[2] FIT + + - FIT blob + - boot configuration file (extlinux.conf) + +-------------------->8-------------------- +menu title UniPhier Boot Options. + +timeout 50 +default UniPhier + +label UniPhier + kernel ../fitImage +-------------------->8-------------------- + +Since the init ramdisk and DTB are contained in the FIT blob, +you do not need to describe them in the configuration file. +Write 'fitImage' and 'extlinux/extlinux.conf' to the file system. + + UniPhier specific commands -------------------------- diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index 31dfd23494..43add0e5a2 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -10,6 +10,35 @@ #ifndef __CONFIG_UNIPHIER_COMMON_H__ #define __CONFIG_UNIPHIER_COMMON_H__ +#ifndef CONFIG_SPL_BUILD +#include + +#ifdef CONFIG_CMD_MMC +#define BOOT_TARGET_DEVICE_MMC(func) func(MMC, mmc, 0) func(MMC, mmc, 1) +#else +#define BOOT_TARGET_DEVICE_MMC(func) +#endif + +#ifdef CONFIG_CMD_UBIFS +#define BOOT_TARGET_DEVICE_UBIFS(func) func(UBIFS, ubifs, 0) +#else +#define BOOT_TARGET_DEVICE_UBIFS(func) +#endif + +#ifdef CONFIG_CMD_USB +#define BOOT_TARGET_DEVICE_USB(func) func(USB, usb, 0) +#else +#define BOOT_TARGET_DEVICE_USB(func) +#endif + +#define BOOT_TARGET_DEVICES(func) \ + BOOT_TARGET_DEVICE_MMC(func) \ + BOOT_TARGET_DEVICE_UBIFS(func) \ + BOOT_TARGET_DEVICE_USB(func) +#else +#define BOOTENV +#endif + #define CONFIG_ARMV7_PSCI_1_0 /*----------------------------------------------------------------------- @@ -98,8 +127,6 @@ "third_image=u-boot.bin\0" #endif -#define CONFIG_BOOTCOMMAND "run $bootmode" - #define CONFIG_ROOTPATH "/nfs/root/path" #define CONFIG_NFSBOOTCOMMAND \ "setenv bootargs $bootargs root=/dev/nfs rw " \ @@ -110,64 +137,31 @@ #ifdef CONFIG_FIT #define CONFIG_BOOTFILE "fitImage" #define LINUXBOOT_ENV_SETTINGS \ - "fit_addr=0x00100000\0" \ - "fit_addr_r=0x85100000\0" \ - "fit_size=0x00f00000\0" \ - "norboot=setexpr fit_addr $nor_base + $fit_addr &&" \ - "bootm $fit_addr\0" \ - "nandboot=nand read $fit_addr_r $fit_addr $fit_size &&" \ - "bootm $fit_addr_r\0" \ - "tftpboot=tftpboot $fit_addr_r $bootfile &&" \ - "bootm $fit_addr_r\0" \ + "kernel_addr_r=0x85100000\0" \ + "tftpboot=tftpboot $kernel_addr_r $bootfile &&" \ + "bootm $kernel_addr_r\0" \ "__nfsboot=run tftpboot\0" #else #ifdef CONFIG_ARM64 -#define CONFIG_BOOTFILE "Image.gz" +#define CONFIG_BOOTFILE "Image" #define LINUXBOOT_CMD "booti" -#define KERNEL_ADDR_LOAD "kernel_addr_load=0x85200000\0" #define KERNEL_ADDR_R "kernel_addr_r=0x82080000\0" #else #define CONFIG_BOOTFILE "zImage" #define LINUXBOOT_CMD "bootz" -#define KERNEL_ADDR_LOAD "kernel_addr_load=0x80208000\0" #define KERNEL_ADDR_R "kernel_addr_r=0x80208000\0" #endif #define LINUXBOOT_ENV_SETTINGS \ - "fdt_addr=0x00100000\0" \ "fdt_addr_r=0x85100000\0" \ - "fdt_size=0x00008000\0" \ - "kernel_addr=0x00200000\0" \ - KERNEL_ADDR_LOAD \ KERNEL_ADDR_R \ - "kernel_size=0x00e00000\0" \ - "ramdisk_addr=0x01000000\0" \ "ramdisk_addr_r=0x86000000\0" \ - "ramdisk_size=0x00800000\0" \ - "ramdisk_file=rootfs.cpio.uboot\0" \ + "ramdisk_file=rootfs.cpio.gz\0" \ "boot_common=setexpr bootm_low $kernel_addr_r '&' fe000000 && " \ - "if test $kernel_addr_load = $kernel_addr_r; then " \ - "true; " \ - "else " \ - "unzip $kernel_addr_load $kernel_addr_r; " \ - "fi && " \ LINUXBOOT_CMD " $kernel_addr_r $ramdisk_addr_r $fdt_addr_r\0" \ - "norboot=setexpr kernel_addr_nor $nor_base + $kernel_addr && " \ - "setexpr kernel_size_div4 $kernel_size / 4 && " \ - "cp $kernel_addr_nor $kernel_addr_load $kernel_size_div4 && " \ - "setexpr ramdisk_addr_nor $nor_base + $ramdisk_addr && " \ - "setexpr ramdisk_size_div4 $ramdisk_size / 4 && " \ - "cp $ramdisk_addr_nor $ramdisk_addr_r $ramdisk_size_div4 && " \ - "setexpr fdt_addr_nor $nor_base + $fdt_addr && " \ - "setexpr fdt_size_div4 $fdt_size / 4 && " \ - "cp $fdt_addr_nor $fdt_addr_r $fdt_size_div4 && " \ - "run boot_common\0" \ - "nandboot=nand read $kernel_addr_load $kernel_addr $kernel_size && " \ - "nand read $ramdisk_addr_r $ramdisk_addr $ramdisk_size &&" \ - "nand read $fdt_addr_r $fdt_addr $fdt_size &&" \ - "run boot_common\0" \ - "tftpboot=tftpboot $kernel_addr_load $bootfile && " \ - "tftpboot $ramdisk_addr_r $ramdisk_file &&" \ + "tftpboot=tftpboot $kernel_addr_r $bootfile && " \ "tftpboot $fdt_addr_r $fdtfile &&" \ + "tftpboot $ramdisk_addr_r $ramdisk_file &&" \ + "setenv ramdisk_addr_r $ramdisk_addr_r:$filesize &&" \ "run boot_common\0" \ "__nfsboot=tftpboot $kernel_addr_load $bootfile && " \ "tftpboot $fdt_addr_r $fdtfile &&" \ @@ -178,6 +172,7 @@ #define CONFIG_EXTRA_ENV_SETTINGS \ "netdev=eth0\0" \ "initrd_high=0xffffffffffffffff\0" \ + "scriptaddr=0x85000000\0" \ "nor_base=0x42000000\0" \ "sramupdate=setexpr tmp_addr $nor_base + 0x50000 &&" \ "tftpboot $tmp_addr $second_image && " \ @@ -201,7 +196,8 @@ "tftpboot $third_image && " \ "usb write $loadaddr 100 f00\0" \ BOOT_IMAGES \ - LINUXBOOT_ENV_SETTINGS + LINUXBOOT_ENV_SETTINGS \ + BOOTENV #define CONFIG_SYS_BOOTMAPSZ 0x20000000