[U-Boot] [PATCH] ads5121: Set offset of NFC registers in device tree.

From: Grzegorz Bernacki gjb@semihalf.com
Offset of NFC register has changed in rev 2 of SoC. U-Boot passes information about it in <offset> property of nfc node.
Signed-off-by: Grzegorz Bernacki gjb@semihalf.com Signed-off-by: Wolfgang Denk wd@denx.de
--- board/ads5121/ads5121.c | 33 +++++++++++++++++++++++++++++++++ include/mpc512x.h | 4 ++++ 2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/board/ads5121/ads5121.c b/board/ads5121/ads5121.c index deaa292..a6cba28 100644 --- a/board/ads5121/ads5121.c +++ b/board/ads5121/ads5121.c @@ -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) */ diff --git a/include/mpc512x.h b/include/mpc512x.h index cb418d1..12f95fb 100644 --- a/include/mpc512x.h +++ b/include/mpc512x.h @@ -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__ */

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.
On Tue, Sep 2, 2008 at 3:41 PM, Wolfgang Denk wd@denx.de wrote:
From: Grzegorz Bernacki gjb@semihalf.com
Offset of NFC register has changed in rev 2 of SoC. U-Boot passes information about it in <offset> property of nfc node.
Signed-off-by: Grzegorz Bernacki gjb@semihalf.com Signed-off-by: Wolfgang Denk wd@denx.de
board/ads5121/ads5121.c | 33 +++++++++++++++++++++++++++++++++ include/mpc512x.h | 4 ++++ 2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/board/ads5121/ads5121.c b/board/ads5121/ads5121.c index deaa292..a6cba28 100644 --- a/board/ads5121/ads5121.c +++ b/board/ads5121/ads5121.c @@ -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) */ diff --git a/include/mpc512x.h b/include/mpc512x.h index cb418d1..12f95fb 100644 --- a/include/mpc512x.h +++ b/include/mpc512x.h @@ -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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Dear "John Rigby",
In message 4b73d43f0809030759g123d5146lc9eb5348799b1838@mail.gmail.com you wrote:
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

On Wed, 2008-09-03 at 22:41 +0200, Wolfgang Denk wrote:
Dear "John Rigby",
In message 4b73d43f0809030759g123d5146lc9eb5348799b1838@mail.gmail.com you wrote:
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.
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

On Thu, Sep 04, 2008 at 10:13:49AM +0200, Kenneth Johansson wrote:
On Wed, 2008-09-03 at 22:41 +0200, Wolfgang Denk wrote:
Dear "John Rigby",
In message 4b73d43f0809030759g123d5146lc9eb5348799b1838@mail.gmail.com you wrote:
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.
s/name/compatible/
-Scott

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";
On Thu, Sep 4, 2008 at 9:05 AM, Scott Wood scottwood@freescale.com wrote:
On Thu, Sep 04, 2008 at 10:13:49AM +0200, Kenneth Johansson wrote:
On Wed, 2008-09-03 at 22:41 +0200, Wolfgang Denk wrote:
Dear "John Rigby",
In message 4b73d43f0809030759g123d5146lc9eb5348799b1838@mail.gmail.com you wrote:
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.
s/name/compatible/
-Scott

Dear John Rigby,
In message 4b73d43f0809041821g3bada7d5i98954bd6f966f1e2@mail.gmail.com you wrote:
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
participants (4)
-
John Rigby
-
Kenneth Johansson
-
Scott Wood
-
Wolfgang Denk