public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1
@ 2023-02-07 14:49 Johan Jonker
  2023-02-07 14:51 ` [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size Johan Jonker
                   ` (10 more replies)
  0 siblings, 11 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:49 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

This serie contains fixes for the Rockchip NFC driver,
which was ported to U-boot and merged with little review
and testing it seems.
Part 1 aims at passing the probe function without errors.

Fixed are:
  64bit FDT parsing
  compatible string removal
  add missing layout structure
  add missing flash_node pointer
  add missing chip ID

Johan Jonker (9):
  include: fdtdec: decouple fdt_addr_t and phys_addr_t size
  include: dm: ofnode: fix headers
  core: remap: convert regmap_init_mem_plat() input to phys_addr_t
  rockchip: adc: rockchip-saradc: convert dev_read_addr output to
    phys_addr_t
  rockchip: timer: dw-apb-timer: convert dev_read_addr output to
    phys_addr_t
  rockchip: mtd: raw: rockchip_nfc convert dev_read_addr output to
    phys_addr_t
  mtd: nand: raw: rockchip_nfc: remove the compatible string
    "rockchip,rk3308-nfc"
  mtd: nand: raw: rockchip_nfc: add layout structure
  mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture

Paweł Jarosz (1):
  mtd: nand: add support for the Sandisk SDTNQGAMA chip

 Kconfig                             |  8 ++++
 drivers/adc/rockchip-saradc.c       |  2 +-
 drivers/core/regmap.c               |  2 +-
 drivers/core/syscon-uclass.c        |  2 +-
 drivers/mtd/nand/raw/nand_ids.c     |  3 ++
 drivers/mtd/nand/raw/rockchip_nfc.c | 68 ++++++++++-------------------
 drivers/ram/rockchip/sdram_rk3066.c |  2 +-
 drivers/ram/rockchip/sdram_rk3188.c |  2 +-
 drivers/ram/rockchip/sdram_rk322x.c |  2 +-
 drivers/ram/rockchip/sdram_rk3288.c |  2 +-
 drivers/ram/rockchip/sdram_rk3328.c |  2 +-
 drivers/ram/rockchip/sdram_rk3399.c |  2 +-
 drivers/timer/dw-apb-timer.c        |  4 +-
 include/dm/ofnode.h                 | 16 +++----
 include/fdtdec.h                    | 13 ++++--
 include/regmap.h                    |  2 +-
 16 files changed, 62 insertions(+), 70 deletions(-)

--
2.20.1


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

* [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
@ 2023-02-07 14:51 ` Johan Jonker
  2023-02-16  7:41   ` Kever Yang
  2023-02-07 14:52 ` [PATCH v2 02/10] include: dm: ofnode: fix headers Johan Jonker
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:51 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The DT specification supports CPUs with both 32-bit and 64-bit addressing
capabilities. In U-boot the fdt_addr_t and phys_addr_t size are coupled
by a typedef. The MTD NAND drivers for 32-bit CPU's can describe partitions
with a 64-bit reg property. These partitions synced from Linux end up with
the wrong offset and sizes when only the lower 32-bit is passed.
Decouple the fdt_addr_t and phys_addr_t size as they don't necessary
match.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changed V2:
  reword

---

Note:
  Most drivers still assume that FDT and CPU capabilities are identical.
  In order to use these variables a cast is needed.
---
 Kconfig          |  8 ++++++++
 include/fdtdec.h | 13 +++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Kconfig b/Kconfig
index a75cce7e..7697dade 100644
--- a/Kconfig
+++ b/Kconfig
@@ -422,11 +422,19 @@ endif # EXPERT

 config PHYS_64BIT
 	bool "64bit physical address support"
+	select FDT_64BIT
 	help
 	  Say Y here to support 64bit physical memory address.
 	  This can be used not only for 64bit SoCs, but also for
 	  large physical address extension on 32bit SoCs.

+config FDT_64BIT
+	bool "64bit fdt address support"
+	help
+	  Say Y here to support 64bit fdt addresses.
+	  This can be used not only for 64bit SoCs, but also
+	  for large address extensions on 32bit SoCs.
+
 config HAS_ROM
 	bool
 	select BINMAN
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 12355afd..af29ac0c 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -18,15 +18,18 @@
 #include <pci.h>

 /*
- * A typedef for a physical address. Note that fdt data is always big
+ * Support for 64bit fdt addresses.
+ * This can be used not only for 64bit SoCs, but also
+ * for large address extensions on 32bit SoCs.
+ * Note that fdt data is always big
  * endian even on a litle endian machine.
  */
-typedef phys_addr_t fdt_addr_t;
-typedef phys_size_t fdt_size_t;

 #define FDT_SIZE_T_NONE (-1U)

-#ifdef CONFIG_PHYS_64BIT
+#ifdef CONFIG_FDT_64BIT
+typedef u64 fdt_addr_t;
+typedef u64 fdt_size_t;
 #define FDT_ADDR_T_NONE ((ulong)(-1))

 #define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
@@ -35,6 +38,8 @@ typedef phys_size_t fdt_size_t;
 #define cpu_to_fdt_size(reg) cpu_to_be64(reg)
 typedef fdt64_t fdt_val_t;
 #else
+typedef u32 fdt_addr_t;
+typedef u32 fdt_size_t;
 #define FDT_ADDR_T_NONE (-1U)

 #define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
--
2.20.1


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

* [PATCH v2 02/10] include: dm: ofnode: fix headers
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
  2023-02-07 14:51 ` [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size Johan Jonker
@ 2023-02-07 14:52 ` Johan Jonker
  2023-02-16  7:41   ` Kever Yang
  2023-02-07 14:52 ` [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t Johan Jonker
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:52 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

When fdt_addr_t and phys_addr_t are split it turns out that
the header don't match the functions, so fix the headers.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 include/dm/ofnode.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index fa986560..287b0c35 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -678,8 +678,8 @@ int ofnode_read_size(ofnode node, const char *propname);
  * @size: Pointer to size of the address
  * Return: address, or FDT_ADDR_T_NONE if not present or invalid
  */
-phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
-				       fdt_size_t *size);
+fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index,
+				      fdt_size_t *size);

 /**
  * ofnode_get_addr_size_index_notrans() - get an address/size from a node
@@ -695,8 +695,8 @@ phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
  * @size: Pointer to size of the address
  * Return: address, or FDT_ADDR_T_NONE if not present or invalid
  */
-phys_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
-					       fdt_size_t *size);
+fdt_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
+					      fdt_size_t *size);

 /**
  * ofnode_get_addr_index() - get an address from a node
@@ -707,7 +707,7 @@ phys_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
  * @index: Index of address to read (0 for first)
  * Return: address, or FDT_ADDR_T_NONE if not present or invalid
  */
-phys_addr_t ofnode_get_addr_index(ofnode node, int index);
+fdt_addr_t ofnode_get_addr_index(ofnode node, int index);

 /**
  * ofnode_get_addr() - get an address from a node
@@ -717,7 +717,7 @@ phys_addr_t ofnode_get_addr_index(ofnode node, int index);
  * @node: node to read from
  * Return: address, or FDT_ADDR_T_NONE if not present or invalid
  */
-phys_addr_t ofnode_get_addr(ofnode node);
+fdt_addr_t ofnode_get_addr(ofnode node);

 /**
  * ofnode_get_size() - get size from a node
@@ -1055,8 +1055,8 @@ const void *ofprop_get_property(const struct ofprop *prop,
  * @sizep: place to put size value (on success)
  * Return: address value, or FDT_ADDR_T_NONE on error
  */
-phys_addr_t ofnode_get_addr_size(ofnode node, const char *propname,
-				 phys_size_t *sizep);
+fdt_addr_t ofnode_get_addr_size(ofnode node, const char *propname,
+				fdt_size_t *sizep);

 /**
  * ofnode_read_u8_array_ptr() - find an 8-bit array
--
2.20.1


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

* [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
  2023-02-07 14:51 ` [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size Johan Jonker
  2023-02-07 14:52 ` [PATCH v2 02/10] include: dm: ofnode: fix headers Johan Jonker
@ 2023-02-07 14:52 ` Johan Jonker
  2023-02-16  7:41   ` Kever Yang
  2023-02-07 14:53 ` [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output " Johan Jonker
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:52 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The fdt_addr_t and phys_addr_t size have been decoupled.
A 32bit CPU can expect 64-bit data from the device tree parser,
so convert regmap_init_mem_plat() input to phys_addr_t in files
that use this function.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/core/regmap.c               | 2 +-
 drivers/core/syscon-uclass.c        | 2 +-
 drivers/ram/rockchip/sdram_rk3066.c | 2 +-
 drivers/ram/rockchip/sdram_rk3188.c | 2 +-
 drivers/ram/rockchip/sdram_rk322x.c | 2 +-
 drivers/ram/rockchip/sdram_rk3288.c | 2 +-
 drivers/ram/rockchip/sdram_rk3328.c | 2 +-
 drivers/ram/rockchip/sdram_rk3399.c | 2 +-
 include/regmap.h                    | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
index e33bb9d7..37da64b2 100644
--- a/drivers/core/regmap.c
+++ b/drivers/core/regmap.c
@@ -79,7 +79,7 @@ static struct regmap *regmap_alloc(int count)
 }

 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
+int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
 			 struct regmap **mapp)
 {
 	struct regmap_range *range;
diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
index 25fdb66e..69b66773 100644
--- a/drivers/core/syscon-uclass.c
+++ b/drivers/core/syscon-uclass.c
@@ -58,7 +58,7 @@ static int syscon_pre_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct syscon_base_plat *plat = dev_get_plat(dev);

-	return regmap_init_mem_plat(dev, plat->reg, ARRAY_SIZE(plat->reg),
+	return regmap_init_mem_plat(dev, (phys_addr_t *)plat->reg, ARRAY_SIZE(plat->reg),
 					&priv->regmap);
 #else
 	return regmap_init_mem(dev_ofnode(dev), &priv->regmap);
diff --git a/drivers/ram/rockchip/sdram_rk3066.c b/drivers/ram/rockchip/sdram_rk3066.c
index a2425f22..9bb26b64 100644
--- a/drivers/ram/rockchip/sdram_rk3066.c
+++ b/drivers/ram/rockchip/sdram_rk3066.c
@@ -801,7 +801,7 @@ static int rk3066_dmc_conv_of_plat(struct udevice *dev)
 	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
 	/* RK3066 supports dual-channel, set default channel num to 2. */
 	plat->num_channels = 1;
-	ret = regmap_init_mem_plat(dev, of_plat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
 				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/drivers/ram/rockchip/sdram_rk3188.c b/drivers/ram/rockchip/sdram_rk3188.c
index 272b1b2d..1838985c 100644
--- a/drivers/ram/rockchip/sdram_rk3188.c
+++ b/drivers/ram/rockchip/sdram_rk3188.c
@@ -867,7 +867,7 @@ static int conv_of_plat(struct udevice *dev)
 	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
 	/* rk3188 supports dual-channel, set default channel num to 2 */
 	plat->num_channels = 1;
-	ret = regmap_init_mem_plat(dev, of_plat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
 				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/drivers/ram/rockchip/sdram_rk322x.c b/drivers/ram/rockchip/sdram_rk322x.c
index 1b204fb5..33599dc5 100644
--- a/drivers/ram/rockchip/sdram_rk322x.c
+++ b/drivers/ram/rockchip/sdram_rk322x.c
@@ -769,7 +769,7 @@ static int conv_of_plat(struct udevice *dev)
 	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));

 	plat->num_channels = 1;
-	ret = regmap_init_mem_plat(dev, of_plat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
 				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/drivers/ram/rockchip/sdram_rk3288.c b/drivers/ram/rockchip/sdram_rk3288.c
index 83778ad1..1a548da5 100644
--- a/drivers/ram/rockchip/sdram_rk3288.c
+++ b/drivers/ram/rockchip/sdram_rk3288.c
@@ -1029,7 +1029,7 @@ static int conv_of_plat(struct udevice *dev)
 	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
 	/* Rk3288 supports dual-channel, set default channel num to 2 */
 	plat->num_channels = 2;
-	ret = regmap_init_mem_plat(dev, of_plat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
 				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/drivers/ram/rockchip/sdram_rk3328.c b/drivers/ram/rockchip/sdram_rk3328.c
index b511c6bf..2427efe0 100644
--- a/drivers/ram/rockchip/sdram_rk3328.c
+++ b/drivers/ram/rockchip/sdram_rk3328.c
@@ -54,7 +54,7 @@ static int conv_of_plat(struct udevice *dev)
 	struct dtd_rockchip_rk3328_dmc *dtplat = &plat->dtplat;
 	int ret;

-	ret = regmap_init_mem_plat(dev, dtplat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
 				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
index 136e4ede..c88fdbb3 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -3049,7 +3049,7 @@ static int conv_of_plat(struct udevice *dev)
 	struct dtd_rockchip_rk3399_dmc *dtplat = &plat->dtplat;
 	int ret;

-	ret = regmap_init_mem_plat(dev, dtplat->reg,
+	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
 				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
 	if (ret)
 		return ret;
diff --git a/include/regmap.h b/include/regmap.h
index e81a3602..a274fb27 100644
--- a/include/regmap.h
+++ b/include/regmap.h
@@ -388,7 +388,7 @@ int regmap_init_mem(ofnode node, struct regmap **mapp);
  * Use regmap_uninit() to free it.
  *
  */
-int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
+int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
 			 struct regmap **mapp);

 int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index);
--
2.20.1


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

* [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output to phys_addr_t
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (2 preceding siblings ...)
  2023-02-07 14:52 ` [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t Johan Jonker
@ 2023-02-07 14:53 ` Johan Jonker
  2023-02-16  7:42   ` Kever Yang
  2023-02-07 14:53 ` [PATCH v2 05/10] rockchip: timer: dw-apb-timer: " Johan Jonker
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:53 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The fdt_addr_t and phys_addr_t size have been decoupled.
A 32bit CPU can expext 64-bit data from the device tree parser,
so convert dev_read_addr output to phys_addr_t in the
rockchip-saradc.c file.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/adc/rockchip-saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
index 760f8fe6..1ba7c483 100644
--- a/drivers/adc/rockchip-saradc.c
+++ b/drivers/adc/rockchip-saradc.c
@@ -145,7 +145,7 @@ int rockchip_saradc_of_to_plat(struct udevice *dev)
 	struct rockchip_saradc_data *data;

 	data = (struct rockchip_saradc_data *)dev_get_driver_data(dev);
-	priv->regs = (struct rockchip_saradc_regs *)dev_read_addr(dev);
+	priv->regs = (struct rockchip_saradc_regs *)((phys_addr_t)dev_read_addr(dev));
 	if (priv->regs == (struct rockchip_saradc_regs *)FDT_ADDR_T_NONE) {
 		pr_err("Dev: %s - can't get address!", dev->name);
 		return -ENODATA;
--
2.20.1


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

* [PATCH v2 05/10] rockchip: timer: dw-apb-timer: convert dev_read_addr output to phys_addr_t
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (3 preceding siblings ...)
  2023-02-07 14:53 ` [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output " Johan Jonker
@ 2023-02-07 14:53 ` Johan Jonker
  2023-02-16  7:42   ` Kever Yang
  2023-02-07 14:54 ` [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc " Johan Jonker
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:53 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The fdt_addr_t and phys_addr_t size have been decoupled.
A 32bit CPU can expect 64-bit data from the device tree parser,
so convert dev_read_addr output to phys_addr_t in the
dw-apb-timer.c file.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/timer/dw-apb-timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c
index 10f0a9f6..f55a3c54 100644
--- a/drivers/timer/dw-apb-timer.c
+++ b/drivers/timer/dw-apb-timer.c
@@ -23,7 +23,7 @@
 #define DW_APB_CTRL		0x8

 struct dw_apb_timer_priv {
-	fdt_addr_t regs;
+	phys_addr_t regs;
 	struct reset_ctl_bulk resets;
 };

@@ -92,7 +92,7 @@ static int dw_apb_timer_of_to_plat(struct udevice *dev)
 	if (CONFIG_IS_ENABLED(OF_REAL)) {
 		struct dw_apb_timer_priv *priv = dev_get_priv(dev);

-		priv->regs = dev_read_addr(dev);
+		priv->regs = (phys_addr_t)dev_read_addr(dev);
 	}

 	return 0;
--
2.20.1


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

* [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc convert dev_read_addr output to phys_addr_t
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (4 preceding siblings ...)
  2023-02-07 14:53 ` [PATCH v2 05/10] rockchip: timer: dw-apb-timer: " Johan Jonker
@ 2023-02-07 14:54 ` Johan Jonker
  2023-02-16  7:34   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  2023-02-07 14:54 ` [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc" Johan Jonker
                   ` (4 subsequent siblings)
  10 siblings, 2 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:54 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The fdt_addr_t and phys_addr_t size have been decoupled.
A 32bit CPU can expext 64-bit data from the device tree parser,
so convert dev_read_addr output to phys_addr_t in the
rockchip_nfc.c file.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index d016d255..78e2a691 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -1180,7 +1180,7 @@ static int rk_nfc_probe(struct udevice *dev)
 	nfc->cfg = (void *)dev_get_driver_data(dev);
 	nfc->dev = dev;

-	nfc->regs = (void *)dev_read_addr(dev);
+	nfc->regs = (void *)((phys_addr_t)dev_read_addr(dev));
 	if (IS_ERR(nfc->regs)) {
 		ret = PTR_ERR(nfc->regs);
 		goto release_nfc;
--
2.20.1


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

* [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc"
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (5 preceding siblings ...)
  2023-02-07 14:54 ` [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc " Johan Jonker
@ 2023-02-07 14:54 ` Johan Jonker
  2023-02-16  7:29   ` Michael Nazzareno Trimarchi
  2023-02-16  7:42   ` Kever Yang
  2023-02-07 14:54 ` [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure Johan Jonker
                   ` (3 subsequent siblings)
  10 siblings, 2 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:54 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The compatible string for rk3308 has as fallback string "rockchip,rv1108-nfc".
As there is no logic in probe priority between the SoC orientated string
and the fall back, so remove the compatible string "rockchip,rk3308-nfc"
from the driver.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index 78e2a691..3809702e 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -1165,10 +1165,6 @@ static const struct udevice_id rk_nfc_id_table[] = {
 		.compatible = "rockchip,rv1108-nfc",
 		.data = (unsigned long)&nfc_v8_cfg
 	},
-	{
-		.compatible = "rockchip,rk3308-nfc",
-		.data = (unsigned long)&nfc_v8_cfg
-	},
 	{ /* sentinel */ }
 };

--
2.20.1


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

* [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (6 preceding siblings ...)
  2023-02-07 14:54 ` [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc" Johan Jonker
@ 2023-02-07 14:54 ` Johan Jonker
  2023-02-16  7:26   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  2023-02-07 14:55 ` [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture Johan Jonker
                   ` (2 subsequent siblings)
  10 siblings, 2 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:54 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The MTD framework in U-boot is not identical for drivers ported
from Linux. The rockchip_nfc driver was ported with OOB ops functions
while the framework expects a layout structure per chip.
Fix by adding a structure with OOB data and remove unused functions.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 61 ++++++++++-------------------
 1 file changed, 20 insertions(+), 41 deletions(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index 3809702e..5e2b8346 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -814,47 +814,9 @@ static void rk_nfc_disable_clks(struct rk_nfc *nfc)
 	clk_disable_unprepare(nfc->ahb_clk);
 }

-static int rk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
-				 struct mtd_oob_region *oob_region)
-{
-	struct nand_chip *chip = mtd_to_nand(mtd);
-	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
-
-	if (section)
-		return -ERANGE;
-
-	/*
-	 * The beginning of the OOB area stores the reserved data for the NFC,
-	 * the size of the reserved data is NFC_SYS_DATA_SIZE bytes.
-	 */
-	oob_region->length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
-	oob_region->offset = NFC_SYS_DATA_SIZE + 2;
-
-	return 0;
-}
-
-static int rk_nfc_ooblayout_ecc(struct mtd_info *mtd, int section,
-				struct mtd_oob_region *oob_region)
-{
-	struct nand_chip *chip = mtd_to_nand(mtd);
-	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
-
-	if (section)
-		return -ERANGE;
-
-	oob_region->length = mtd->oobsize - rknand->metadata_size;
-	oob_region->offset = rknand->metadata_size;
-
-	return 0;
-}
-
-static const struct mtd_ooblayout_ops rk_nfc_ooblayout_ops = {
-	.rfree = rk_nfc_ooblayout_free,
-	.ecc = rk_nfc_ooblayout_ecc,
-};
-
 static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
 {
+	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
 	const u8 *strengths = nfc->cfg->ecc_strengths;
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	struct nand_ecc_ctrl *ecc = &chip->ecc;
@@ -892,6 +854,21 @@ static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
 	ecc->steps = mtd->writesize / ecc->size;
 	ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * chip->ecc.size), 8);

+	if (ecc->bytes * ecc->steps > mtd->oobsize - rknand->metadata_size)
+		return -EINVAL;
+
+	ecc->layout = kzalloc(sizeof(*ecc->layout), GFP_KERNEL);
+	if (!ecc->layout)
+		return -ENOMEM;
+
+	ecc->layout->eccbytes = ecc->bytes * ecc->steps;
+
+	for (i = 0; i < ecc->layout->eccbytes; i++)
+		ecc->layout->eccpos[i] = rknand->metadata_size + i;
+
+	ecc->layout->oobfree[0].length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
+	ecc->layout->oobfree[0].offset = NFC_SYS_DATA_SIZE + 2;
+
 	return 0;
 }

@@ -969,7 +946,6 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
 	chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
 	chip->options |= NAND_NO_SUBPAGE_WRITE | NAND_USE_BOUNCE_BUFFER;

-	mtd_set_ooblayout(mtd, &rk_nfc_ooblayout_ops);
 	rk_nfc_hw_init(nfc);
 	ret = nand_scan_ident(mtd, nsels, NULL);
 	if (ret)
@@ -998,13 +974,16 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)

 	if (!nfc->page_buf) {
 		nfc->page_buf = kzalloc(NFC_MAX_PAGE_SIZE, GFP_KERNEL);
-		if (!nfc->page_buf)
+		if (!nfc->page_buf) {
+			kfree(ecc->layout);
 			return -ENOMEM;
+		}
 	}

 	if (!nfc->oob_buf) {
 		nfc->oob_buf = kzalloc(NFC_MAX_OOB_SIZE, GFP_KERNEL);
 		if (!nfc->oob_buf) {
+			kfree(ecc->layout);
 			kfree(nfc->page_buf);
 			nfc->page_buf = NULL;
 			return -ENOMEM;
--
2.20.1


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

* [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (7 preceding siblings ...)
  2023-02-07 14:54 ` [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure Johan Jonker
@ 2023-02-07 14:55 ` Johan Jonker
  2023-02-16  7:24   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  2023-02-07 14:56 ` [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip Johan Jonker
  2023-02-13 14:18 ` [PATCH v1] mtd: nand: raw: rockchip_nfc: fix oobfree offset and description Johan Jonker
  10 siblings, 2 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:55 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

Add flash_node to the rockchip_nfc driver chip stucture in order
to find the partitions in the add_mtd_partitions_of() functions.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index 5e2b8346..9e3a2533 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -934,6 +934,7 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)

 	nand_set_controller_data(chip, nfc);

+	chip->flash_node = node;
 	chip->chip_delay = NFC_RB_DELAY_US;
 	chip->select_chip = rk_nfc_select_chip;
 	chip->cmd_ctrl = rk_nfc_cmd;
--
2.20.1


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

* [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (8 preceding siblings ...)
  2023-02-07 14:55 ` [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture Johan Jonker
@ 2023-02-07 14:56 ` Johan Jonker
  2023-02-16  7:43   ` Kever Yang
  2023-02-13 14:18 ` [PATCH v1] mtd: nand: raw: rockchip_nfc: fix oobfree offset and description Johan Jonker
  10 siblings, 1 reply; 26+ messages in thread
From: Johan Jonker @ 2023-02-07 14:56 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

Sandisk SDTNQGAMA is a 8GB size, 3.3V 8 bit chip with 16KB page size, 1KB write size and 40 bit ecc support

Signed-off-by: Paweł Jarosz <paweljarosz3691@gmail.com>
Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mtd/nand/raw/nand_ids.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c
index d0cfacc6..22ea5e2f 100644
--- a/drivers/mtd/nand/raw/nand_ids.c
+++ b/drivers/mtd/nand/raw/nand_ids.c
@@ -48,6 +48,9 @@ struct nand_flash_dev nand_flash_ids[] = {
 	{"TC58NVG6D2 64G 3.3V 8-bit",
 		{ .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} },
 		  SZ_8K, SZ_8K, SZ_2M, 0, 8, 640, NAND_ECC_INFO(40, SZ_1K) },
+	{"SDTNQGAMA 64G 3.3V 8-bit",
+		{ .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x57} },
+		  SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
 	{"SDTNRGAMA 64G 3.3V 8-bit",
 		{ .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x50} },
 		  SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
--
2.20.1


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

* [PATCH v1] mtd: nand: raw: rockchip_nfc: fix oobfree offset and description
  2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
                   ` (9 preceding siblings ...)
  2023-02-07 14:56 ` [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip Johan Jonker
@ 2023-02-13 14:18 ` Johan Jonker
  10 siblings, 0 replies; 26+ messages in thread
From: Johan Jonker @ 2023-02-13 14:18 UTC (permalink / raw)
  To: dario.binacchi, michael, sjg
  Cc: philipp.tomsich, kever.yang, u-boot, yifeng.zhao

The MTD framework reserves 1 or 2 bytes for the bad block marker
depending on the bus size. The rockchip_nfc driver currently only
supports a 8 bit bus, but reserves standard 2 bytes for the BBM.
The first free OOB byte is therefore OOB2 at offset 2.
Page address(PA) bytes are moved to the last 4 positions before
ECC. Update the description for U-boot.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

Note:
  Merge after serie:
    [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
index 9e3a2533..bcab219b 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -487,10 +487,10 @@ static int rk_nfc_write_page_raw(struct mtd_info *mtd,
 		 *
 		 *    BBM  OOB1 OOB2 OOB3 |......|  PA0  PA1  PA2  PA3
 		 *
-		 * The rk_nfc_ooblayout_free() function already has reserved
-		 * these 4 bytes with:
+		 * The oobfree structure already has reserved these 4 bytes
+		 * together with 2 bytes for BBM by reducing it's length:
 		 *
-		 * oob_region->offset = NFC_SYS_DATA_SIZE + 2;
+		 * oobfree[0].length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
 		 */
 		if (!i)
 			memcpy(rk_nfc_oob_ptr(chip, i),
@@ -867,7 +867,7 @@ static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
 		ecc->layout->eccpos[i] = rknand->metadata_size + i;

 	ecc->layout->oobfree[0].length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
-	ecc->layout->oobfree[0].offset = NFC_SYS_DATA_SIZE + 2;
+	ecc->layout->oobfree[0].offset = 2;

 	return 0;
 }
--
2.20.1


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

* Re: [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture
  2023-02-07 14:55 ` [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture Johan Jonker
@ 2023-02-16  7:24   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-02-16  7:24 UTC (permalink / raw)
  To: Johan Jonker
  Cc: dario.binacchi, sjg, philipp.tomsich, kever.yang, u-boot,
	yifeng.zhao

Hi

On Tue, Feb 7, 2023 at 3:55 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> Add flash_node to the rockchip_nfc driver chip stucture in order
> to find the partitions in the add_mtd_partitions_of() functions.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>  drivers/mtd/nand/raw/rockchip_nfc.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 5e2b8346..9e3a2533 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -934,6 +934,7 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>
>         nand_set_controller_data(chip, nfc);
>
> +       chip->flash_node = node;
>         chip->chip_delay = NFC_RB_DELAY_US;
>         chip->select_chip = rk_nfc_select_chip;
>         chip->cmd_ctrl = rk_nfc_cmd;
> --
> 2.20.1
>

Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>

-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure
  2023-02-07 14:54 ` [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure Johan Jonker
@ 2023-02-16  7:26   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-02-16  7:26 UTC (permalink / raw)
  To: Johan Jonker
  Cc: dario.binacchi, sjg, philipp.tomsich, kever.yang, u-boot,
	yifeng.zhao

Hi

On Tue, Feb 7, 2023 at 3:55 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> The MTD framework in U-boot is not identical for drivers ported
> from Linux. The rockchip_nfc driver was ported with OOB ops functions
> while the framework expects a layout structure per chip.
> Fix by adding a structure with OOB data and remove unused functions.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>  drivers/mtd/nand/raw/rockchip_nfc.c | 61 ++++++++++-------------------
>  1 file changed, 20 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 3809702e..5e2b8346 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -814,47 +814,9 @@ static void rk_nfc_disable_clks(struct rk_nfc *nfc)
>         clk_disable_unprepare(nfc->ahb_clk);
>  }
>
> -static int rk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
> -                                struct mtd_oob_region *oob_region)
> -{
> -       struct nand_chip *chip = mtd_to_nand(mtd);
> -       struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
> -
> -       if (section)
> -               return -ERANGE;
> -
> -       /*
> -        * The beginning of the OOB area stores the reserved data for the NFC,
> -        * the size of the reserved data is NFC_SYS_DATA_SIZE bytes.
> -        */
> -       oob_region->length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
> -       oob_region->offset = NFC_SYS_DATA_SIZE + 2;
> -
> -       return 0;
> -}
> -
> -static int rk_nfc_ooblayout_ecc(struct mtd_info *mtd, int section,
> -                               struct mtd_oob_region *oob_region)
> -{
> -       struct nand_chip *chip = mtd_to_nand(mtd);
> -       struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
> -
> -       if (section)
> -               return -ERANGE;
> -
> -       oob_region->length = mtd->oobsize - rknand->metadata_size;
> -       oob_region->offset = rknand->metadata_size;
> -
> -       return 0;
> -}
> -
> -static const struct mtd_ooblayout_ops rk_nfc_ooblayout_ops = {
> -       .rfree = rk_nfc_ooblayout_free,
> -       .ecc = rk_nfc_ooblayout_ecc,
> -};
> -
>  static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
>  {
> +       struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
>         const u8 *strengths = nfc->cfg->ecc_strengths;
>         struct mtd_info *mtd = nand_to_mtd(chip);
>         struct nand_ecc_ctrl *ecc = &chip->ecc;
> @@ -892,6 +854,21 @@ static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
>         ecc->steps = mtd->writesize / ecc->size;
>         ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * chip->ecc.size), 8);
>
> +       if (ecc->bytes * ecc->steps > mtd->oobsize - rknand->metadata_size)
> +               return -EINVAL;
> +
> +       ecc->layout = kzalloc(sizeof(*ecc->layout), GFP_KERNEL);
> +       if (!ecc->layout)
> +               return -ENOMEM;
> +
> +       ecc->layout->eccbytes = ecc->bytes * ecc->steps;
> +
> +       for (i = 0; i < ecc->layout->eccbytes; i++)
> +               ecc->layout->eccpos[i] = rknand->metadata_size + i;
> +
> +       ecc->layout->oobfree[0].length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
> +       ecc->layout->oobfree[0].offset = NFC_SYS_DATA_SIZE + 2;
> +
>         return 0;
>  }
>
> @@ -969,7 +946,6 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>         chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
>         chip->options |= NAND_NO_SUBPAGE_WRITE | NAND_USE_BOUNCE_BUFFER;
>
> -       mtd_set_ooblayout(mtd, &rk_nfc_ooblayout_ops);
>         rk_nfc_hw_init(nfc);
>         ret = nand_scan_ident(mtd, nsels, NULL);
>         if (ret)
> @@ -998,13 +974,16 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>
>         if (!nfc->page_buf) {
>                 nfc->page_buf = kzalloc(NFC_MAX_PAGE_SIZE, GFP_KERNEL);
> -               if (!nfc->page_buf)
> +               if (!nfc->page_buf) {
> +                       kfree(ecc->layout);
>                         return -ENOMEM;
> +               }
>         }
>
>         if (!nfc->oob_buf) {
>                 nfc->oob_buf = kzalloc(NFC_MAX_OOB_SIZE, GFP_KERNEL);
>                 if (!nfc->oob_buf) {
> +                       kfree(ecc->layout);
>                         kfree(nfc->page_buf);
>                         nfc->page_buf = NULL;
>                         return -ENOMEM;
> --
> 2.20.1
>

Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>

-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc"
  2023-02-07 14:54 ` [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc" Johan Jonker
@ 2023-02-16  7:29   ` Michael Nazzareno Trimarchi
  2023-02-16  7:42   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-02-16  7:29 UTC (permalink / raw)
  To: Johan Jonker
  Cc: dario.binacchi, sjg, philipp.tomsich, kever.yang, u-boot,
	yifeng.zhao

Hi Johan

On Tue, Feb 7, 2023 at 3:54 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> The compatible string for rk3308 has as fallback string "rockchip,rv1108-nfc".
> As there is no logic in probe priority between the SoC orientated string
> and the fall back, so remove the compatible string "rockchip,rk3308-nfc"
> from the driver.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>  drivers/mtd/nand/raw/rockchip_nfc.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 78e2a691..3809702e 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -1165,10 +1165,6 @@ static const struct udevice_id rk_nfc_id_table[] = {
>                 .compatible = "rockchip,rv1108-nfc",
>                 .data = (unsigned long)&nfc_v8_cfg
>         },
> -       {
> -               .compatible = "rockchip,rk3308-nfc",
> -               .data = (unsigned long)&nfc_v8_cfg
> -       },

Ok, same on linux

Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>

>         { /* sentinel */ }
>  };
>
> --
> 2.20.1
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc convert dev_read_addr output to phys_addr_t
  2023-02-07 14:54 ` [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc " Johan Jonker
@ 2023-02-16  7:34   ` Michael Nazzareno Trimarchi
  2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Michael Nazzareno Trimarchi @ 2023-02-16  7:34 UTC (permalink / raw)
  To: Johan Jonker
  Cc: dario.binacchi, sjg, philipp.tomsich, kever.yang, u-boot,
	yifeng.zhao

Hi Johan

On Tue, Feb 7, 2023 at 3:54 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expext 64-bit data from the device tree parser,
> so convert dev_read_addr output to phys_addr_t in the
> rockchip_nfc.c file.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>  drivers/mtd/nand/raw/rockchip_nfc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index d016d255..78e2a691 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -1180,7 +1180,7 @@ static int rk_nfc_probe(struct udevice *dev)
>         nfc->cfg = (void *)dev_get_driver_data(dev);
>         nfc->dev = dev;
>
> -       nfc->regs = (void *)dev_read_addr(dev);
> +       nfc->regs = (void *)((phys_addr_t)dev_read_addr(dev));

Is phy_read_addr_ptr() family supposed to be used in this case?

Michael

>         if (IS_ERR(nfc->regs)) {
>                 ret = PTR_ERR(nfc->regs);
>                 goto release_nfc;
> --
> 2.20.1
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size
  2023-02-07 14:51 ` [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size Johan Jonker
@ 2023-02-16  7:41   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:41 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:51, Johan Jonker wrote:
> The DT specification supports CPUs with both 32-bit and 64-bit addressing
> capabilities. In U-boot the fdt_addr_t and phys_addr_t size are coupled
> by a typedef. The MTD NAND drivers for 32-bit CPU's can describe partitions
> with a 64-bit reg property. These partitions synced from Linux end up with
> the wrong offset and sizes when only the lower 32-bit is passed.
> Decouple the fdt_addr_t and phys_addr_t size as they don't necessary
> match.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>
> Changed V2:
>    reword
>
> ---
>
> Note:
>    Most drivers still assume that FDT and CPU capabilities are identical.
>    In order to use these variables a cast is needed.
> ---
>   Kconfig          |  8 ++++++++
>   include/fdtdec.h | 13 +++++++++----
>   2 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/Kconfig b/Kconfig
> index a75cce7e..7697dade 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -422,11 +422,19 @@ endif # EXPERT
>
>   config PHYS_64BIT
>   	bool "64bit physical address support"
> +	select FDT_64BIT
>   	help
>   	  Say Y here to support 64bit physical memory address.
>   	  This can be used not only for 64bit SoCs, but also for
>   	  large physical address extension on 32bit SoCs.
>
> +config FDT_64BIT
> +	bool "64bit fdt address support"
> +	help
> +	  Say Y here to support 64bit fdt addresses.
> +	  This can be used not only for 64bit SoCs, but also
> +	  for large address extensions on 32bit SoCs.
> +
>   config HAS_ROM
>   	bool
>   	select BINMAN
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index 12355afd..af29ac0c 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -18,15 +18,18 @@
>   #include <pci.h>
>
>   /*
> - * A typedef for a physical address. Note that fdt data is always big
> + * Support for 64bit fdt addresses.
> + * This can be used not only for 64bit SoCs, but also
> + * for large address extensions on 32bit SoCs.
> + * Note that fdt data is always big
>    * endian even on a litle endian machine.
>    */
> -typedef phys_addr_t fdt_addr_t;
> -typedef phys_size_t fdt_size_t;
>
>   #define FDT_SIZE_T_NONE (-1U)
>
> -#ifdef CONFIG_PHYS_64BIT
> +#ifdef CONFIG_FDT_64BIT
> +typedef u64 fdt_addr_t;
> +typedef u64 fdt_size_t;
>   #define FDT_ADDR_T_NONE ((ulong)(-1))
>
>   #define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
> @@ -35,6 +38,8 @@ typedef phys_size_t fdt_size_t;
>   #define cpu_to_fdt_size(reg) cpu_to_be64(reg)
>   typedef fdt64_t fdt_val_t;
>   #else
> +typedef u32 fdt_addr_t;
> +typedef u32 fdt_size_t;
>   #define FDT_ADDR_T_NONE (-1U)
>
>   #define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
> --
> 2.20.1
>

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

* Re: [PATCH v2 02/10] include: dm: ofnode: fix headers
  2023-02-07 14:52 ` [PATCH v2 02/10] include: dm: ofnode: fix headers Johan Jonker
@ 2023-02-16  7:41   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:41 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:52, Johan Jonker wrote:
> When fdt_addr_t and phys_addr_t are split it turns out that
> the header don't match the functions, so fix the headers.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   include/dm/ofnode.h | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index fa986560..287b0c35 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -678,8 +678,8 @@ int ofnode_read_size(ofnode node, const char *propname);
>    * @size: Pointer to size of the address
>    * Return: address, or FDT_ADDR_T_NONE if not present or invalid
>    */
> -phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
> -				       fdt_size_t *size);
> +fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index,
> +				      fdt_size_t *size);
>
>   /**
>    * ofnode_get_addr_size_index_notrans() - get an address/size from a node
> @@ -695,8 +695,8 @@ phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
>    * @size: Pointer to size of the address
>    * Return: address, or FDT_ADDR_T_NONE if not present or invalid
>    */
> -phys_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
> -					       fdt_size_t *size);
> +fdt_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
> +					      fdt_size_t *size);
>
>   /**
>    * ofnode_get_addr_index() - get an address from a node
> @@ -707,7 +707,7 @@ phys_addr_t ofnode_get_addr_size_index_notrans(ofnode node, int index,
>    * @index: Index of address to read (0 for first)
>    * Return: address, or FDT_ADDR_T_NONE if not present or invalid
>    */
> -phys_addr_t ofnode_get_addr_index(ofnode node, int index);
> +fdt_addr_t ofnode_get_addr_index(ofnode node, int index);
>
>   /**
>    * ofnode_get_addr() - get an address from a node
> @@ -717,7 +717,7 @@ phys_addr_t ofnode_get_addr_index(ofnode node, int index);
>    * @node: node to read from
>    * Return: address, or FDT_ADDR_T_NONE if not present or invalid
>    */
> -phys_addr_t ofnode_get_addr(ofnode node);
> +fdt_addr_t ofnode_get_addr(ofnode node);
>
>   /**
>    * ofnode_get_size() - get size from a node
> @@ -1055,8 +1055,8 @@ const void *ofprop_get_property(const struct ofprop *prop,
>    * @sizep: place to put size value (on success)
>    * Return: address value, or FDT_ADDR_T_NONE on error
>    */
> -phys_addr_t ofnode_get_addr_size(ofnode node, const char *propname,
> -				 phys_size_t *sizep);
> +fdt_addr_t ofnode_get_addr_size(ofnode node, const char *propname,
> +				fdt_size_t *sizep);
>
>   /**
>    * ofnode_read_u8_array_ptr() - find an 8-bit array
> --
> 2.20.1
>

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

* Re: [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t
  2023-02-07 14:52 ` [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t Johan Jonker
@ 2023-02-16  7:41   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:41 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:52, Johan Jonker wrote:
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expect 64-bit data from the device tree parser,
> so convert regmap_init_mem_plat() input to phys_addr_t in files
> that use this function.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/core/regmap.c               | 2 +-
>   drivers/core/syscon-uclass.c        | 2 +-
>   drivers/ram/rockchip/sdram_rk3066.c | 2 +-
>   drivers/ram/rockchip/sdram_rk3188.c | 2 +-
>   drivers/ram/rockchip/sdram_rk322x.c | 2 +-
>   drivers/ram/rockchip/sdram_rk3288.c | 2 +-
>   drivers/ram/rockchip/sdram_rk3328.c | 2 +-
>   drivers/ram/rockchip/sdram_rk3399.c | 2 +-
>   include/regmap.h                    | 2 +-
>   9 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
> index e33bb9d7..37da64b2 100644
> --- a/drivers/core/regmap.c
> +++ b/drivers/core/regmap.c
> @@ -79,7 +79,7 @@ static struct regmap *regmap_alloc(int count)
>   }
>
>   #if CONFIG_IS_ENABLED(OF_PLATDATA)
> -int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
> +int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
>   			 struct regmap **mapp)
>   {
>   	struct regmap_range *range;
> diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
> index 25fdb66e..69b66773 100644
> --- a/drivers/core/syscon-uclass.c
> +++ b/drivers/core/syscon-uclass.c
> @@ -58,7 +58,7 @@ static int syscon_pre_probe(struct udevice *dev)
>   #if CONFIG_IS_ENABLED(OF_PLATDATA)
>   	struct syscon_base_plat *plat = dev_get_plat(dev);
>
> -	return regmap_init_mem_plat(dev, plat->reg, ARRAY_SIZE(plat->reg),
> +	return regmap_init_mem_plat(dev, (phys_addr_t *)plat->reg, ARRAY_SIZE(plat->reg),
>   					&priv->regmap);
>   #else
>   	return regmap_init_mem(dev_ofnode(dev), &priv->regmap);
> diff --git a/drivers/ram/rockchip/sdram_rk3066.c b/drivers/ram/rockchip/sdram_rk3066.c
> index a2425f22..9bb26b64 100644
> --- a/drivers/ram/rockchip/sdram_rk3066.c
> +++ b/drivers/ram/rockchip/sdram_rk3066.c
> @@ -801,7 +801,7 @@ static int rk3066_dmc_conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* RK3066 supports dual-channel, set default channel num to 2. */
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3188.c b/drivers/ram/rockchip/sdram_rk3188.c
> index 272b1b2d..1838985c 100644
> --- a/drivers/ram/rockchip/sdram_rk3188.c
> +++ b/drivers/ram/rockchip/sdram_rk3188.c
> @@ -867,7 +867,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* rk3188 supports dual-channel, set default channel num to 2 */
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk322x.c b/drivers/ram/rockchip/sdram_rk322x.c
> index 1b204fb5..33599dc5 100644
> --- a/drivers/ram/rockchip/sdram_rk322x.c
> +++ b/drivers/ram/rockchip/sdram_rk322x.c
> @@ -769,7 +769,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3288.c b/drivers/ram/rockchip/sdram_rk3288.c
> index 83778ad1..1a548da5 100644
> --- a/drivers/ram/rockchip/sdram_rk3288.c
> +++ b/drivers/ram/rockchip/sdram_rk3288.c
> @@ -1029,7 +1029,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* Rk3288 supports dual-channel, set default channel num to 2 */
>   	plat->num_channels = 2;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3328.c b/drivers/ram/rockchip/sdram_rk3328.c
> index b511c6bf..2427efe0 100644
> --- a/drivers/ram/rockchip/sdram_rk3328.c
> +++ b/drivers/ram/rockchip/sdram_rk3328.c
> @@ -54,7 +54,7 @@ static int conv_of_plat(struct udevice *dev)
>   	struct dtd_rockchip_rk3328_dmc *dtplat = &plat->dtplat;
>   	int ret;
>
> -	ret = regmap_init_mem_plat(dev, dtplat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
>   				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
> index 136e4ede..c88fdbb3 100644
> --- a/drivers/ram/rockchip/sdram_rk3399.c
> +++ b/drivers/ram/rockchip/sdram_rk3399.c
> @@ -3049,7 +3049,7 @@ static int conv_of_plat(struct udevice *dev)
>   	struct dtd_rockchip_rk3399_dmc *dtplat = &plat->dtplat;
>   	int ret;
>
> -	ret = regmap_init_mem_plat(dev, dtplat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
>   				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/include/regmap.h b/include/regmap.h
> index e81a3602..a274fb27 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -388,7 +388,7 @@ int regmap_init_mem(ofnode node, struct regmap **mapp);
>    * Use regmap_uninit() to free it.
>    *
>    */
> -int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
> +int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
>   			 struct regmap **mapp);
>
>   int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index);
> --
> 2.20.1
>

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

* Re: [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output to phys_addr_t
  2023-02-07 14:53 ` [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output " Johan Jonker
@ 2023-02-16  7:42   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:42 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:53, Johan Jonker wrote:
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expext 64-bit data from the device tree parser,
> so convert dev_read_addr output to phys_addr_t in the
> rockchip-saradc.c file.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/adc/rockchip-saradc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/adc/rockchip-saradc.c b/drivers/adc/rockchip-saradc.c
> index 760f8fe6..1ba7c483 100644
> --- a/drivers/adc/rockchip-saradc.c
> +++ b/drivers/adc/rockchip-saradc.c
> @@ -145,7 +145,7 @@ int rockchip_saradc_of_to_plat(struct udevice *dev)
>   	struct rockchip_saradc_data *data;
>
>   	data = (struct rockchip_saradc_data *)dev_get_driver_data(dev);
> -	priv->regs = (struct rockchip_saradc_regs *)dev_read_addr(dev);
> +	priv->regs = (struct rockchip_saradc_regs *)((phys_addr_t)dev_read_addr(dev));
>   	if (priv->regs == (struct rockchip_saradc_regs *)FDT_ADDR_T_NONE) {
>   		pr_err("Dev: %s - can't get address!", dev->name);
>   		return -ENODATA;
> --
> 2.20.1
>

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

* Re: [PATCH v2 05/10] rockchip: timer: dw-apb-timer: convert dev_read_addr output to phys_addr_t
  2023-02-07 14:53 ` [PATCH v2 05/10] rockchip: timer: dw-apb-timer: " Johan Jonker
@ 2023-02-16  7:42   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:42 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:53, Johan Jonker wrote:
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expect 64-bit data from the device tree parser,
> so convert dev_read_addr output to phys_addr_t in the
> dw-apb-timer.c file.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/timer/dw-apb-timer.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/timer/dw-apb-timer.c b/drivers/timer/dw-apb-timer.c
> index 10f0a9f6..f55a3c54 100644
> --- a/drivers/timer/dw-apb-timer.c
> +++ b/drivers/timer/dw-apb-timer.c
> @@ -23,7 +23,7 @@
>   #define DW_APB_CTRL		0x8
>
>   struct dw_apb_timer_priv {
> -	fdt_addr_t regs;
> +	phys_addr_t regs;
>   	struct reset_ctl_bulk resets;
>   };
>
> @@ -92,7 +92,7 @@ static int dw_apb_timer_of_to_plat(struct udevice *dev)
>   	if (CONFIG_IS_ENABLED(OF_REAL)) {
>   		struct dw_apb_timer_priv *priv = dev_get_priv(dev);
>
> -		priv->regs = dev_read_addr(dev);
> +		priv->regs = (phys_addr_t)dev_read_addr(dev);
>   	}
>
>   	return 0;
> --
> 2.20.1
>

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

* Re: [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc"
  2023-02-07 14:54 ` [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc" Johan Jonker
  2023-02-16  7:29   ` Michael Nazzareno Trimarchi
@ 2023-02-16  7:42   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:42 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:54, Johan Jonker wrote:
> The compatible string for rk3308 has as fallback string "rockchip,rv1108-nfc".
> As there is no logic in probe priority between the SoC orientated string
> and the fall back, so remove the compatible string "rockchip,rk3308-nfc"
> from the driver.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/mtd/nand/raw/rockchip_nfc.c | 4 ----
>   1 file changed, 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 78e2a691..3809702e 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -1165,10 +1165,6 @@ static const struct udevice_id rk_nfc_id_table[] = {
>   		.compatible = "rockchip,rv1108-nfc",
>   		.data = (unsigned long)&nfc_v8_cfg
>   	},
> -	{
> -		.compatible = "rockchip,rk3308-nfc",
> -		.data = (unsigned long)&nfc_v8_cfg
> -	},
>   	{ /* sentinel */ }
>   };
>
> --
> 2.20.1
>

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

* Re: [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure
  2023-02-07 14:54 ` [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure Johan Jonker
  2023-02-16  7:26   ` Michael Nazzareno Trimarchi
@ 2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:43 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:54, Johan Jonker wrote:
> The MTD framework in U-boot is not identical for drivers ported
> from Linux. The rockchip_nfc driver was ported with OOB ops functions
> while the framework expects a layout structure per chip.
> Fix by adding a structure with OOB data and remove unused functions.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/mtd/nand/raw/rockchip_nfc.c | 61 ++++++++++-------------------
>   1 file changed, 20 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 3809702e..5e2b8346 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -814,47 +814,9 @@ static void rk_nfc_disable_clks(struct rk_nfc *nfc)
>   	clk_disable_unprepare(nfc->ahb_clk);
>   }
>
> -static int rk_nfc_ooblayout_free(struct mtd_info *mtd, int section,
> -				 struct mtd_oob_region *oob_region)
> -{
> -	struct nand_chip *chip = mtd_to_nand(mtd);
> -	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
> -
> -	if (section)
> -		return -ERANGE;
> -
> -	/*
> -	 * The beginning of the OOB area stores the reserved data for the NFC,
> -	 * the size of the reserved data is NFC_SYS_DATA_SIZE bytes.
> -	 */
> -	oob_region->length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
> -	oob_region->offset = NFC_SYS_DATA_SIZE + 2;
> -
> -	return 0;
> -}
> -
> -static int rk_nfc_ooblayout_ecc(struct mtd_info *mtd, int section,
> -				struct mtd_oob_region *oob_region)
> -{
> -	struct nand_chip *chip = mtd_to_nand(mtd);
> -	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
> -
> -	if (section)
> -		return -ERANGE;
> -
> -	oob_region->length = mtd->oobsize - rknand->metadata_size;
> -	oob_region->offset = rknand->metadata_size;
> -
> -	return 0;
> -}
> -
> -static const struct mtd_ooblayout_ops rk_nfc_ooblayout_ops = {
> -	.rfree = rk_nfc_ooblayout_free,
> -	.ecc = rk_nfc_ooblayout_ecc,
> -};
> -
>   static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
>   {
> +	struct rk_nfc_nand_chip *rknand = rk_nfc_to_rknand(chip);
>   	const u8 *strengths = nfc->cfg->ecc_strengths;
>   	struct mtd_info *mtd = nand_to_mtd(chip);
>   	struct nand_ecc_ctrl *ecc = &chip->ecc;
> @@ -892,6 +854,21 @@ static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct nand_chip *chip)
>   	ecc->steps = mtd->writesize / ecc->size;
>   	ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * chip->ecc.size), 8);
>
> +	if (ecc->bytes * ecc->steps > mtd->oobsize - rknand->metadata_size)
> +		return -EINVAL;
> +
> +	ecc->layout = kzalloc(sizeof(*ecc->layout), GFP_KERNEL);
> +	if (!ecc->layout)
> +		return -ENOMEM;
> +
> +	ecc->layout->eccbytes = ecc->bytes * ecc->steps;
> +
> +	for (i = 0; i < ecc->layout->eccbytes; i++)
> +		ecc->layout->eccpos[i] = rknand->metadata_size + i;
> +
> +	ecc->layout->oobfree[0].length = rknand->metadata_size - NFC_SYS_DATA_SIZE - 2;
> +	ecc->layout->oobfree[0].offset = NFC_SYS_DATA_SIZE + 2;
> +
>   	return 0;
>   }
>
> @@ -969,7 +946,6 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>   	chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
>   	chip->options |= NAND_NO_SUBPAGE_WRITE | NAND_USE_BOUNCE_BUFFER;
>
> -	mtd_set_ooblayout(mtd, &rk_nfc_ooblayout_ops);
>   	rk_nfc_hw_init(nfc);
>   	ret = nand_scan_ident(mtd, nsels, NULL);
>   	if (ret)
> @@ -998,13 +974,16 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>
>   	if (!nfc->page_buf) {
>   		nfc->page_buf = kzalloc(NFC_MAX_PAGE_SIZE, GFP_KERNEL);
> -		if (!nfc->page_buf)
> +		if (!nfc->page_buf) {
> +			kfree(ecc->layout);
>   			return -ENOMEM;
> +		}
>   	}
>
>   	if (!nfc->oob_buf) {
>   		nfc->oob_buf = kzalloc(NFC_MAX_OOB_SIZE, GFP_KERNEL);
>   		if (!nfc->oob_buf) {
> +			kfree(ecc->layout);
>   			kfree(nfc->page_buf);
>   			nfc->page_buf = NULL;
>   			return -ENOMEM;
> --
> 2.20.1
>

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

* Re: [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture
  2023-02-07 14:55 ` [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture Johan Jonker
  2023-02-16  7:24   ` Michael Nazzareno Trimarchi
@ 2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:43 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:55, Johan Jonker wrote:
> Add flash_node to the rockchip_nfc driver chip stucture in order
> to find the partitions in the add_mtd_partitions_of() functions.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/mtd/nand/raw/rockchip_nfc.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index 5e2b8346..9e3a2533 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -934,6 +934,7 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
>
>   	nand_set_controller_data(chip, nfc);
>
> +	chip->flash_node = node;
>   	chip->chip_delay = NFC_RB_DELAY_US;
>   	chip->select_chip = rk_nfc_select_chip;
>   	chip->cmd_ctrl = rk_nfc_cmd;
> --
> 2.20.1
>

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

* Re: [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip
  2023-02-07 14:56 ` [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip Johan Jonker
@ 2023-02-16  7:43   ` Kever Yang
  0 siblings, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:43 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:56, Johan Jonker wrote:
> Sandisk SDTNQGAMA is a 8GB size, 3.3V 8 bit chip with 16KB page size, 1KB write size and 40 bit ecc support
>
> Signed-off-by: Paweł Jarosz <paweljarosz3691@gmail.com>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/mtd/nand/raw/nand_ids.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/nand_ids.c b/drivers/mtd/nand/raw/nand_ids.c
> index d0cfacc6..22ea5e2f 100644
> --- a/drivers/mtd/nand/raw/nand_ids.c
> +++ b/drivers/mtd/nand/raw/nand_ids.c
> @@ -48,6 +48,9 @@ struct nand_flash_dev nand_flash_ids[] = {
>   	{"TC58NVG6D2 64G 3.3V 8-bit",
>   		{ .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} },
>   		  SZ_8K, SZ_8K, SZ_2M, 0, 8, 640, NAND_ECC_INFO(40, SZ_1K) },
> +	{"SDTNQGAMA 64G 3.3V 8-bit",
> +		{ .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x57} },
> +		  SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
>   	{"SDTNRGAMA 64G 3.3V 8-bit",
>   		{ .id = {0x45, 0xde, 0x94, 0x93, 0x76, 0x50} },
>   		  SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) },
> --
> 2.20.1
>

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

* Re: [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc convert dev_read_addr output to phys_addr_t
  2023-02-07 14:54 ` [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc " Johan Jonker
  2023-02-16  7:34   ` Michael Nazzareno Trimarchi
@ 2023-02-16  7:43   ` Kever Yang
  1 sibling, 0 replies; 26+ messages in thread
From: Kever Yang @ 2023-02-16  7:43 UTC (permalink / raw)
  To: Johan Jonker, dario.binacchi, michael, sjg
  Cc: philipp.tomsich, u-boot, yifeng.zhao


On 2023/2/7 22:54, Johan Jonker wrote:
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expext 64-bit data from the device tree parser,
> so convert dev_read_addr output to phys_addr_t in the
> rockchip_nfc.c file.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   drivers/mtd/nand/raw/rockchip_nfc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c b/drivers/mtd/nand/raw/rockchip_nfc.c
> index d016d255..78e2a691 100644
> --- a/drivers/mtd/nand/raw/rockchip_nfc.c
> +++ b/drivers/mtd/nand/raw/rockchip_nfc.c
> @@ -1180,7 +1180,7 @@ static int rk_nfc_probe(struct udevice *dev)
>   	nfc->cfg = (void *)dev_get_driver_data(dev);
>   	nfc->dev = dev;
>
> -	nfc->regs = (void *)dev_read_addr(dev);
> +	nfc->regs = (void *)((phys_addr_t)dev_read_addr(dev));
>   	if (IS_ERR(nfc->regs)) {
>   		ret = PTR_ERR(nfc->regs);
>   		goto release_nfc;
> --
> 2.20.1
>

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

end of thread, other threads:[~2023-02-16  7:44 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07 14:49 [PATCH v2 00/10] Fixes for Rockchip NFC driver part 1 Johan Jonker
2023-02-07 14:51 ` [PATCH v2 01/10] include: fdtdec: decouple fdt_addr_t and phys_addr_t size Johan Jonker
2023-02-16  7:41   ` Kever Yang
2023-02-07 14:52 ` [PATCH v2 02/10] include: dm: ofnode: fix headers Johan Jonker
2023-02-16  7:41   ` Kever Yang
2023-02-07 14:52 ` [PATCH v2 03/10] core: remap: convert regmap_init_mem_plat() input to phys_addr_t Johan Jonker
2023-02-16  7:41   ` Kever Yang
2023-02-07 14:53 ` [PATCH v2 04/10] rockchip: adc: rockchip-saradc: convert dev_read_addr output " Johan Jonker
2023-02-16  7:42   ` Kever Yang
2023-02-07 14:53 ` [PATCH v2 05/10] rockchip: timer: dw-apb-timer: " Johan Jonker
2023-02-16  7:42   ` Kever Yang
2023-02-07 14:54 ` [PATCH v2 06/10] rockchip: mtd: raw: rockchip_nfc " Johan Jonker
2023-02-16  7:34   ` Michael Nazzareno Trimarchi
2023-02-16  7:43   ` Kever Yang
2023-02-07 14:54 ` [PATCH v2 07/10] mtd: nand: raw: rockchip_nfc: remove the compatible string "rockchip,rk3308-nfc" Johan Jonker
2023-02-16  7:29   ` Michael Nazzareno Trimarchi
2023-02-16  7:42   ` Kever Yang
2023-02-07 14:54 ` [PATCH v2 08/10] mtd: nand: raw: rockchip_nfc: add layout structure Johan Jonker
2023-02-16  7:26   ` Michael Nazzareno Trimarchi
2023-02-16  7:43   ` Kever Yang
2023-02-07 14:55 ` [PATCH v2 09/10] mtd: nand: raw: rockchip_nfc: add flash_node to chip stucture Johan Jonker
2023-02-16  7:24   ` Michael Nazzareno Trimarchi
2023-02-16  7:43   ` Kever Yang
2023-02-07 14:56 ` [PATCH v2 10/10] mtd: nand: add support for the Sandisk SDTNQGAMA chip Johan Jonker
2023-02-16  7:43   ` Kever Yang
2023-02-13 14:18 ` [PATCH v1] mtd: nand: raw: rockchip_nfc: fix oobfree offset and description Johan Jonker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox