]> git.sur5r.net Git - u-boot/blobdiff - arch/powerpc/cpu/mpc85xx/fdt.c
GCC4.6: Squash warnings in denali_spd_ddr2.c
[u-boot] / arch / powerpc / cpu / mpc85xx / fdt.c
index c62b12fb1d1124750fbd263f69cbefe34f22ac5c..9d31568412a30c89bf63641599d789075551d827 100644 (file)
@@ -361,6 +361,7 @@ void fdt_add_enet_stashing(void *fdt)
 }
 
 #if defined(CONFIG_SYS_DPAA_FMAN) || defined(CONFIG_SYS_DPAA_PME)
+#ifdef CONFIG_SYS_DPAA_FMAN
 static void ft_fixup_clks(void *blob, const char *compat, u32 offset,
                          unsigned long freq)
 {
@@ -374,12 +375,14 @@ static void ft_fixup_clks(void *blob, const char *compat, u32 offset,
                                "for %s: %s\n", compat, fdt_strerror(off));
        }
 }
+#endif
 
 static void ft_fixup_dpaa_clks(void *blob)
 {
        sys_info_t sysinfo;
 
        get_sys_info(&sysinfo);
+#ifdef CONFIG_SYS_DPAA_FMAN
        ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM1_OFFSET,
                        sysinfo.freqFMan[0]);
 
@@ -387,6 +390,7 @@ static void ft_fixup_dpaa_clks(void *blob)
        ft_fixup_clks(blob, "fsl,fman", CONFIG_SYS_FSL_FM2_OFFSET,
                        sysinfo.freqFMan[1]);
 #endif
+#endif
 
 #ifdef CONFIG_SYS_DPAA_PME
        do_fixup_by_compat_u32(blob, "fsl,pme",
@@ -500,9 +504,8 @@ void fdt_fixup_fman_firmware(void *blob)
                       fdt_strerror(rc));
                return;
        }
-       phandle = fdt_alloc_phandle(blob);
-       rc = fdt_setprop_cell(blob, fwnode, "linux,phandle", phandle);
-       if (rc < 0) {
+       phandle = fdt_create_phandle(blob, fwnode);
+       if (!phandle) {
                char s[64];
                fdt_get_path(blob, fwnode, s, sizeof(s));
                printf("Could not add phandle property to node %s: %s\n", s,
@@ -534,6 +537,27 @@ void fdt_fixup_fman_firmware(void *blob)
 #define fdt_fixup_fman_firmware(x)
 #endif
 
+#if defined(CONFIG_PPC_P4080) || defined(CONFIG_PPC_P3060)
+static void fdt_fixup_usb(void *fdt)
+{
+       ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+       u32 rcwsr11 = in_be32(&gur->rcwsr[11]);
+       int off;
+
+       off = fdt_node_offset_by_compatible(fdt, -1, "fsl,mpc85xx-usb2-mph");
+       if ((rcwsr11 & FSL_CORENET_RCWSR11_EC1) !=
+                               FSL_CORENET_RCWSR11_EC1_FM1_USB1)
+               fdt_status_disabled(fdt, off);
+
+       off = fdt_node_offset_by_compatible(fdt, -1, "fsl,mpc85xx-usb2-dr");
+       if ((rcwsr11 & FSL_CORENET_RCWSR11_EC2) !=
+                               FSL_CORENET_RCWSR11_EC2_USB2)
+               fdt_status_disabled(fdt, off);
+}
+#else
+#define fdt_fixup_usb(x)
+#endif
+
 void ft_cpu_setup(void *blob, bd_t *bd)
 {
        int off;
@@ -638,4 +662,78 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 
        do_fixup_by_compat_u32(blob, "fsl,flexcan-v1.0",
                        "clock_freq", gd->bus_clk, 1);
+
+       fdt_fixup_usb(blob);
+}
+
+/*
+ * For some CCSR devices, we only have the virtual address, not the physical
+ * address.  This is because we map CCSR as a whole, so we typically don't need
+ * a macro for the physical address of any device within CCSR.  In this case,
+ * we calculate the physical address of that device using it's the difference
+ * between the virtual address of the device and the virtual address of the
+ * beginning of CCSR.
+ */
+#define CCSR_VIRT_TO_PHYS(x) \
+       (CONFIG_SYS_CCSRBAR_PHYS + ((x) - CONFIG_SYS_CCSRBAR))
+
+/*
+ * Verify the device tree
+ *
+ * This function compares several CONFIG_xxx macros that contain physical
+ * addresses with the corresponding nodes in the device tree, to see if
+ * the physical addresses are all correct.  For example, if
+ * CONFIG_SYS_NS16550_COM1 is defined, then it contains the virtual address
+ * of the first UART.  We convert this to a physical address and compare
+ * that with the physical address of the first ns16550-compatible node
+ * in the device tree.  If they don't match, then we display a warning.
+ *
+ * Returns 1 on success, 0 on failure
+ */
+int ft_verify_fdt(void *fdt)
+{
+       uint64_t ccsr = 0;
+       int aliases;
+       int off;
+
+       /* First check the CCSR base address */
+       off = fdt_node_offset_by_prop_value(fdt, -1, "device_type", "soc", 4);
+       if (off > 0)
+               ccsr = fdt_get_base_address(fdt, off);
+
+       if (!ccsr) {
+               printf("Warning: could not determine base CCSR address in "
+                      "device tree\n");
+               /* No point in checking anything else */
+               return 0;
+       }
+
+       if (ccsr != CONFIG_SYS_CCSRBAR_PHYS) {
+               printf("Warning: U-Boot configured CCSR at address %llx,\n"
+                      "but the device tree has it at %llx\n",
+                      (uint64_t) CONFIG_SYS_CCSRBAR_PHYS, ccsr);
+               /* No point in checking anything else */
+               return 0;
+       }
+
+       /*
+        * Get the 'aliases' node.  If there isn't one, then there's nothing
+        * left to do.
+        */
+       aliases = fdt_path_offset(fdt, "/aliases");
+       if (aliases > 0) {
+#ifdef CONFIG_SYS_NS16550_COM1
+               if (!fdt_verify_alias_address(fdt, aliases, "serial0",
+                       CCSR_VIRT_TO_PHYS(CONFIG_SYS_NS16550_COM1)))
+                       return 0;
+#endif
+
+#ifdef CONFIG_SYS_NS16550_COM2
+               if (!fdt_verify_alias_address(fdt, aliases, "serial1",
+                       CCSR_VIRT_TO_PHYS(CONFIG_SYS_NS16550_COM2)))
+                       return 0;
+#endif
+       }
+
+       return 1;
 }