Merge branch 'master' of git://git.denx.de/u-boot-marvell
[platform/kernel/u-boot.git] / arch / powerpc / cpu / mpc8xxx / fdt.c
index 79d3cdf..54e60bb 100644 (file)
 #include <common.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#include <asm/mp.h>
+#include <asm/fsl_enet.h>
+
+#if defined(CONFIG_MP) && (defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx))
+static int ft_del_cpuhandle(void *blob, int cpuhandle)
+{
+       int off, ret = -FDT_ERR_NOTFOUND;
+
+       /* if we find a match, we'll delete at it which point the offsets are
+        * invalid so we start over from the beginning
+        */
+       off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle",
+                                               &cpuhandle, 4);
+       while (off != -FDT_ERR_NOTFOUND) {
+               fdt_delprop(blob, off, "cpu-handle");
+               ret = 1;
+               off = fdt_node_offset_by_prop_value(blob, -1, "cpu-handle",
+                               &cpuhandle, 4);
+       }
+
+       return ret;
+}
 
-#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
 void ft_fixup_num_cores(void *blob) {
        int off, num_cores, del_cores;
 
@@ -38,13 +59,18 @@ void ft_fixup_num_cores(void *blob) {
        while (off != -FDT_ERR_NOTFOUND) {
                u32 *reg = (u32 *)fdt_getprop(blob, off, "reg", 0);
 
-               /* if we find a cpu node outside of what we expect delete it
-                * and reset the offset back to the start since we can't
-                * trust the offsets anymore
-                */
-               if (*reg > num_cores-1) {
-                       fdt_del_node(blob, off);
-                       del_cores++;
+               if ((*reg > num_cores-1) || (is_core_disabled(*reg))) {
+                       int ph = fdt_get_phandle(blob, off);
+
+                       /* Delete the cpu node once there are no cpu handles */
+                       if (-FDT_ERR_NOTFOUND == ft_del_cpuhandle(blob, ph)) {
+                               fdt_del_node(blob, off);
+                               del_cores++;
+                       }
+                       /* either we deleted some cpu handles or the cpu node
+                        * so we reset the offset back to the start since we
+                        * can't trust the offsets anymore
+                        */
                        off = -1;
                }
                off = fdt_node_offset_by_prop_value(blob, off,
@@ -97,11 +123,11 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
 }
 #endif /* CONFIG_HAS_FSL_DR_USB */
 
-#if defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx)
 /*
  * update crypto node properties to a specified revision of the SEC
- * called with sec_rev == 0 if not on an mpc8xxxE processor
+ * called with sec_rev == 0 if not on an E processor
  */
+#if CONFIG_SYS_FSL_SEC_COMPAT == 2 /* SEC 2.x/3.x */
 void fdt_fixup_crypto_node(void *blob, int sec_rev)
 {
        const struct sec_rev_prop {
@@ -183,4 +209,33 @@ void fdt_fixup_crypto_node(void *blob, int sec_rev)
                printf("WARNING: could not set crypto property: %s\n",
                       fdt_strerror(err));
 }
-#endif /* defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) */
+#elif CONFIG_SYS_FSL_SEC_COMPAT >= 4  /* SEC4 */
+void fdt_fixup_crypto_node(void *blob, int sec_rev)
+{
+       if (!sec_rev)
+               fdt_del_node_and_alias(blob, "crypto");
+}
+#endif
+
+int fdt_fixup_phy_connection(void *blob, int offset, enum fsl_phy_enet_if phyc)
+{
+       static const char *fsl_phy_enet_if_str[] = {
+               [MII]           = "mii",
+               [RMII]          = "rmii",
+               [GMII]          = "gmii",
+               [RGMII]         = "rgmii",
+               [RGMII_ID]      = "rgmii-id",
+               [RGMII_RXID]    = "rgmii-rxid",
+               [SGMII]         = "sgmii",
+               [TBI]           = "tbi",
+               [RTBI]          = "rtbi",
+               [XAUI]          = "xgmii",
+               [FSL_ETH_IF_NONE] = "",
+       };
+
+       if (phyc > ARRAY_SIZE(fsl_phy_enet_if_str))
+               return fdt_setprop_string(blob, offset, "phy-connection-type", "");
+
+       return fdt_setprop_string(blob, offset, "phy-connection-type",
+                                        fsl_phy_enet_if_str[phyc]);
+}