Skip to contentSkip to conversation

ads5121: Set offset of NFC registers in device tree.

PATCH New Wolfgang Denk 4 participants 7 messages Sep 2, 2008 – Sep 6, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

From: Grzegorz Bernacki <[email protected]>

Offset of NFC register has changed in rev 2 of SoC. U-Boot passes information about it in <offset> property of nfc node.

---
 board/ads5121/ads5121.c |   33 +++++++++++++++++++++++++++++++++
 include/mpc512x.h       |    4 ++++
 2 files changed, 37 insertions(+), 0 deletions(-)
board/ads5121/ads5121.c +33 -0
index deaa292..a6cba28 100644
@@ -27,6 +27,7 @@
 #include <command.h>
 #include <asm/processor.h>
 #include <fdt_support.h>
+#include <libfdt.h>
 #ifdef CONFIG_MISC_INIT_R
 #include <i2c.h>
 #endif
@@ -306,9 +307,41 @@ int checkboard (void)
 }
 
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
+static int fdt_set_nfc_offset(void* blob)
+{
+	int err, nodeoffset;
+	unsigned int offset;
+	volatile immap_t *im = (immap_t *) CFG_IMMR;
+
+	if (SVR_MJREV (im->sysconf.spridr) >= 2)
+		offset = NFC_REV2_REG_OFFSET;
+	else
+		offset = NFC_REG_OFFSET;
+
+	err = fdt_check_header(blob);
+	if (err < 0) {
+		printf("%s: %s\n", __FUNCTION__, fdt_strerror(err));
+		return err;
+	}
+
+	/*  update nfc node */
+	nodeoffset = fdt_path_offset(blob, "/nfc");
+	if (nodeoffset < 0)
+		return 0;
+
+	err = fdt_setprop(blob, nodeoffset, "offset", &offset, sizeof(offset));
+	if (err < 0) {
+		printf("WARNING: could not set NFC offset property %s.\n",
+			fdt_strerror(err));
+		return err;
+	}
+
+}
+
 void ft_board_setup(void *blob, bd_t *bd)
 {
 	ft_cpu_setup(blob, bd);
 	fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+	fdt_set_nfc_offset(blob);
 }
 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
include/mpc512x.h +4 -0
index cb418d1..12f95fb 100644
@@ -674,4 +674,8 @@ void iopin_initialize(iopin_t *,int);
 #define PIWAR_IWS_1G			0x0000001D
 #define PIWAR_IWS_2G			0x0000001E
 
+/* NAND Flash controller registers offset */
+#define NFC_REG_OFFSET			0x0E00
+#define NFC_REV2_REG_OFFSET		0x1E00
+
 #endif	/* __MPC512X_H__ */
Signature · 1 line
1.5.4.2
#1 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

I'm not sure this right way to deal with this. Even with the modified offset the 1.5 silicon linux nand driver will not work correctly with the 2.0 silicon nand controller.

Quoted 88 lines · Wolfgang Denk

From: Grzegorz Bernacki <[email protected]>

Offset of NFC register has changed in rev 2 of SoC. U-Boot passes information about it in <offset> property of nfc node.

---
 board/ads5121/ads5121.c |   33 +++++++++++++++++++++++++++++++++
 include/mpc512x.h       |    4 ++++
 2 files changed, 37 insertions(+), 0 deletions(-)
board/ads5121/ads5121.c +33 -0
index deaa292..a6cba28 100644
@@ -27,6 +27,7 @@
 #include <command.h>
 #include <asm/processor.h>
 #include <fdt_support.h>
+#include <libfdt.h>
 #ifdef CONFIG_MISC_INIT_R
 #include <i2c.h>
 #endif
@@ -306,9 +307,41 @@ int checkboard (void)
 }
 
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
+static int fdt_set_nfc_offset(void* blob)
+{
+       int err, nodeoffset;
+       unsigned int offset;
+       volatile immap_t *im = (immap_t *) CFG_IMMR;
+
+       if (SVR_MJREV (im->sysconf.spridr) >= 2)
+               offset = NFC_REV2_REG_OFFSET;
+       else
+               offset = NFC_REG_OFFSET;
+
+       err = fdt_check_header(blob);
+       if (err < 0) {
+               printf("%s: %s\n", __FUNCTION__, fdt_strerror(err));
+               return err;
+       }
+
+       /*  update nfc node */
+       nodeoffset = fdt_path_offset(blob, "/nfc");
+       if (nodeoffset < 0)
+               return 0;
+
+       err = fdt_setprop(blob, nodeoffset, "offset", &offset, sizeof(offset));
+       if (err < 0) {
+               printf("WARNING: could not set NFC offset property %s.\n",
+                       fdt_strerror(err));
+               return err;
+       }
+
+}
+
 void ft_board_setup(void *blob, bd_t *bd)
 {
       ft_cpu_setup(blob, bd);
       fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
+       fdt_set_nfc_offset(blob);
 }
 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
include/mpc512x.h +4 -1
index cb418d1..12f95fb 100644
@@ -674,4 +674,8 @@ void iopin_initialize(iopin_t *,int);
 #define PIWAR_IWS_1G                   0x0000001D
 #define PIWAR_IWS_2G                   0x0000001E
 
+/* NAND Flash controller registers offset */
+#define NFC_REG_OFFSET                 0x0E00
+#define NFC_REV2_REG_OFFSET            0x1E00
+
 #endif /* __MPC512X_H__ */
--

1.5.4.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#2 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

Dear "John Rigby",

Quoted 3 lines · In message <[email protected]> you…

I'm not sure this right way to deal with this. Even with the modified offset the 1.5 silicon linux nand driver will not work correctly with the 2.0 silicon nand controller.

That's right - but al least the Linux kernel will not crash if used on one or the other board.

I think we should fix the NFC base address on the device tree level - having to support different Linux kernel configurations depending on if you are on old or new hardware is pretty painful.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The man on tops walks a lonely street;  the  "chain"  of  command  is
often a noose.
#3 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

Quoted 9 lines · Wolfgang Denk

Dear "John Rigby",

Quoted 3 lines · In message <[email protected]> you…

I'm not sure this right way to deal with this. Even with the modified offset the 1.5 silicon linux nand driver will not work correctly with the 2.0 silicon nand controller.

That's right - but al least the Linux kernel will not crash if used on one or the other board.

yes but due to the large difference you will probably never se one driver supporting both version so just changing the name of the hardware node is probably easier.

Quoted 8 lines

I think we should fix the NFC base address on the device tree level - having to support different Linux kernel configurations depending on if you are on old or new hardware is pretty painful.

Best regards,

Wolfgang Denk

#4 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

Quoted 8 lines · Kenneth Johansson
Quoted 7 lines · Wolfgang Denk

Dear "John Rigby",

Quoted 3 lines · In message <[email protected]> you…

I'm not sure this right way to deal with this. Even with the modified offset the 1.5 silicon linux nand driver will not work correctly with the 2.0 silicon nand controller.

Quoted 6 lines
Quoted 2 lines

That's right - but al least the Linux kernel will not crash if used on one or the other board.

yes but due to the large difference you will probably never se one driver supporting both version so just changing the name of the hardware node is probably easier.

s/name/compatible/

-Scott

#5 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

I agree, here are the two device tree entries:
Original silicon rev 1 and 1.5:

		compatible = "fsl,mpc5121-nfc";
rev 2:
		compatible = "fsl,mpc5121rev2-nfc";
Quoted 20 lines · Scott Wood
Quoted 8 lines · Kenneth Johansson
Quoted 7 lines · Wolfgang Denk

Dear "John Rigby",

Quoted 3 lines · In message <[email protected]> you…

I'm not sure this right way to deal with this. Even with the modified offset the 1.5 silicon linux nand driver will not work correctly with the 2.0 silicon nand controller.

Quoted 6 lines
Quoted 2 lines

That's right - but al least the Linux kernel will not crash if used on one or the other board.

yes but due to the large difference you will probably never se one driver supporting both version so just changing the name of the hardware node is probably easier.

s/name/compatible/

-Scott

#6 lore raw

PATCH 1/1 ads5121: Set offset of NFC registers in device tree.

Dear John Rigby,

Quoted 5 lines · In message <[email protected]> you…

I agree, here are the two device tree entries:
Original silicon rev 1 and 1.5:

		compatible = "fsl,mpc5121-nfc";
rev 2:
		compatible = "fsl,mpc5121rev2-nfc";

Actually I woner it it makes sense at all to attempt to support the old (pre-rev. 2 silicon based) hardware at all in newer versions of U-Boot and Linux. There are only a few boards out in the field, and those of the customers who are actually doing any work on them will replace them by new hardware anyway. The others can stick as well with the existing U-Boot and Linux support.

I vote to support only rev. 2 (and later) silicon in recent versions of U-Boot and Linux.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An optimist believes we live in the best world possible; a  pessimist
fears this is true.