mpc8641: fix address-cells default in old .dts detection
[oweals/u-boot.git] / board / freescale / mpc8641hpcn / mpc8641hpcn.c
index 5af5c4b8374c0d1f03452a5a15263b335554972a..b83ed6c45669e8e5b11c712f2103e12eb9538682 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "../common/pixis.h"
 
-long int fixed_sdram(void);
+phys_size_t fixed_sdram(void);
 
 int board_early_init_f(void)
 {
@@ -53,7 +53,7 @@ int checkboard(void)
 phys_size_t
 initdram(int board_type)
 {
-       long dram_size = 0;
+       phys_size_t dram_size = 0;
 
 #if defined(CONFIG_SPD_EEPROM)
        dram_size = fsl_ddr_sdram();
@@ -75,7 +75,7 @@ initdram(int board_type)
 /*
  * Fixed sdram init -- doesn't use serial presence detect.
  */
-long int
+phys_size_t
 fixed_sdram(void)
 {
 #if !defined(CONFIG_SYS_RAMBOOT)
@@ -249,11 +249,15 @@ void pci_init_board(void)
 
 #if defined(CONFIG_OF_BOARD_SETUP)
 extern void ft_fsl_pci_setup(void *blob, const char *pci_alias,
-                        struct pci_controller *hose);
+                       struct pci_controller *hose);
 
 void
 ft_board_setup(void *blob, bd_t *bd)
 {
+       int off;
+       u64 *tmp;
+       u32 *addrcells;
+
        ft_cpu_setup(blob, bd);
 
 #ifdef CONFIG_PCI1
@@ -262,6 +266,29 @@ ft_board_setup(void *blob, bd_t *bd)
 #ifdef CONFIG_PCI2
        ft_fsl_pci_setup(blob, "pci1", &pci2_hose);
 #endif
+
+       /*
+        * Warn if it looks like the device tree doesn't match u-boot.
+        * This is just an estimation, based on the location of CCSR,
+        * which is defined by the "reg" property in the soc node.
+        */
+       off = fdt_path_offset(blob, "/soc8641");
+       addrcells = (u32 *)fdt_getprop(blob, 0, "#address-cells", NULL);
+       tmp = (u64 *)fdt_getprop(blob, off, "reg", NULL);
+
+       if (tmp) {
+               u64 addr;
+               if (addrcells && (*addrcells == 1))
+                       addr = *(u32 *)tmp;
+               else
+                       addr = *tmp;
+
+               if (addr != CONFIG_SYS_CCSRBAR_PHYS)
+                       printf("WARNING: The CCSRBAR address in your .dts "
+                              "does not match the address of the CCSR "
+                              "in u-boot.  This means your .dts might "
+                              "be old.\n");
+       }
 }
 #endif