All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific
@ 2018-07-19  7:28 Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 2/6] board: constify struct node_info array Masahiro Yamada
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

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 <yamada.masahiro@socionext.com>
---

 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 812eca8..3b31f3d 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 a9a0078..27fe564 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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/6] board: constify struct node_info array
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
@ 2018-07-19  7:28 ` Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 3/6] ARM: uniphier: clean-up ft_board_setup() Masahiro Yamada
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

Add 'const' (also 'static' in some places) to struct node_info
arrays to save memory footprint.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 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 c0f33b8..9eec1b7 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 c114cdc..d42f57d 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 at 02100000/usdhc at 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 367152f..9d9c83f 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 6885668..36a5528 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 b86924e..c4ec974 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 cc55bcc..965a009 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 45a414c..367af82 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 cd98ec8..c05ca0c 100644
--- a/board/toradex/colibri_imx7/colibri_imx7.c
+++ b/board/toradex/colibri_imx7/colibri_imx7.c
@@ -408,7 +408,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 */
 	};
 
diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index 83c3503..4db1757 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 */
 	};
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/6] ARM: uniphier: clean-up ft_board_setup()
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 2/6] board: constify struct node_info array Masahiro Yamada
@ 2018-07-19  7:28 ` Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 4/6] ARM: uniphier: split ft_board_setup() out to a separate file Masahiro Yamada
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

The 'bd' is passed in ft_board_setup() as the second argument.
Replace 'gd->bd' with 'bd'.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 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 2eb4836..8aa3f81 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);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 4/6] ARM: uniphier: split ft_board_setup() out to a separate file
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 2/6] board: constify struct node_info array Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 3/6] ARM: uniphier: clean-up ft_board_setup() Masahiro Yamada
@ 2018-07-19  7:28 ` Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 5/6] ARM: uniphier: support fdt_fixup_mtdparts Masahiro Yamada
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

Prepare to add more fdt fixup code.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 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 5b3746c..ebd7c9a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1221,6 +1221,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 91bea77..c199374 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 269c51b..d0c39d42 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 8aa3f81..7e7c1d9 100644
--- a/arch/arm/mach-uniphier/dram_init.c
+++ b/arch/arm/mach-uniphier/dram_init.c
@@ -6,8 +6,6 @@
  */
 
 #include <common.h>
-#include <fdt_support.h>
-#include <fdtdec.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/printk.h>
@@ -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 0000000..022e442
--- /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 <yamada.masahiro@socionext.com>
+ */
+
+#include <common.h>
+#include <fdt_support.h>
+#include <fdtdec.h>
+#include <linux/kernel.h>
+#include <linux/printk.h>
+
+#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;
+}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 5/6] ARM: uniphier: support fdt_fixup_mtdparts
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
                   ` (2 preceding siblings ...)
  2018-07-19  7:28 ` [U-Boot] [PATCH 4/6] ARM: uniphier: split ft_board_setup() out to a separate file Masahiro Yamada
@ 2018-07-19  7:28 ` Masahiro Yamada
  2018-07-19  7:28 ` [U-Boot] [PATCH 6/6] ARM: uniphier: enable MTD partition and UBI Masahiro Yamada
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

Propagate the "mtdparts" environment variable to the DT passed
in to OS.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 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 022e442..6f3c29d 100644
--- a/arch/arm/mach-uniphier/fdt-fixup.c
+++ b/arch/arm/mach-uniphier/fdt-fixup.c
@@ -7,6 +7,8 @@
 #include <common.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
+#include <jffs2/load_kernel.h>
+#include <mtd_node.h>
 #include <linux/kernel.h>
 #include <linux/printk.h>
 
@@ -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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 6/6] ARM: uniphier: enable MTD partition and UBI
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
                   ` (3 preceding siblings ...)
  2018-07-19  7:28 ` [U-Boot] [PATCH 5/6] ARM: uniphier: support fdt_fixup_mtdparts Masahiro Yamada
@ 2018-07-19  7:28 ` Masahiro Yamada
  2018-07-19 15:21 ` [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Simon Glass
  2018-07-24 23:43 ` Masahiro Yamada
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-19  7:28 UTC (permalink / raw)
  To: u-boot

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 <yamada.masahiro@socionext.com>
---

 configs/uniphier_ld4_sld8_defconfig | 4 ++++
 configs/uniphier_v7_defconfig       | 4 ++++
 configs/uniphier_v8_defconfig       | 4 ++++
 include/configs/uniphier.h          | 1 +
 4 files changed, 13 insertions(+)

diff --git a/configs/uniphier_ld4_sld8_defconfig b/configs/uniphier_ld4_sld8_defconfig
index e5c1deb..225be21 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
@@ -52,3 +55,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 89b7b4a..c54ee00 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
@@ -53,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
diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig
index 93df2f6..67ebde7 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
@@ -53,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
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index b631f79..49eb18f 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -26,6 +26,7 @@
 
 /* FLASH related */
 #define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
 
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_CFI
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
                   ` (4 preceding siblings ...)
  2018-07-19  7:28 ` [U-Boot] [PATCH 6/6] ARM: uniphier: enable MTD partition and UBI Masahiro Yamada
@ 2018-07-19 15:21 ` Simon Glass
  2018-07-24 23:43 ` Masahiro Yamada
  6 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2018-07-19 15:21 UTC (permalink / raw)
  To: u-boot

Hi Masahiro,

On 19 July 2018 at 01:28, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> 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 <yamada.masahiro@socionext.com>
> ---
>
>  common/fdt_support.c  | 13 +++++++------
>  include/fdt_support.h | 11 ++++++++---
>  2 files changed, 15 insertions(+), 9 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific
  2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
                   ` (5 preceding siblings ...)
  2018-07-19 15:21 ` [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Simon Glass
@ 2018-07-24 23:43 ` Masahiro Yamada
  6 siblings, 0 replies; 8+ messages in thread
From: Masahiro Yamada @ 2018-07-24 23:43 UTC (permalink / raw)
  To: u-boot

2018-07-19 16:28 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> 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 <yamada.masahiro@socionext.com>
> ---


Series, applied to u-boot-uniphier.


>  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 812eca8..3b31f3d 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 a9a0078..27fe564 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);
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-24 23:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19  7:28 [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Masahiro Yamada
2018-07-19  7:28 ` [U-Boot] [PATCH 2/6] board: constify struct node_info array Masahiro Yamada
2018-07-19  7:28 ` [U-Boot] [PATCH 3/6] ARM: uniphier: clean-up ft_board_setup() Masahiro Yamada
2018-07-19  7:28 ` [U-Boot] [PATCH 4/6] ARM: uniphier: split ft_board_setup() out to a separate file Masahiro Yamada
2018-07-19  7:28 ` [U-Boot] [PATCH 5/6] ARM: uniphier: support fdt_fixup_mtdparts Masahiro Yamada
2018-07-19  7:28 ` [U-Boot] [PATCH 6/6] ARM: uniphier: enable MTD partition and UBI Masahiro Yamada
2018-07-19 15:21 ` [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific Simon Glass
2018-07-24 23:43 ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.