]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
powerpc/85xx: Update device tree handling for SRIO
authorKumar Gala <galak@kernel.crashing.org>
Fri, 14 Oct 2011 05:03:58 +0000 (00:03 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Tue, 18 Oct 2011 05:36:43 +0000 (00:36 -0500)
Update device tree handling for SRIO controller to support updated
fsl,srio device tree binding.

We handle disabling of individual ports, the whole controller, RMU, and
RMAN.  Additionally, we setup the SRIO related LIODNs in the device
tree.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/cpu/mpc85xx/liodn.c
arch/powerpc/cpu/mpc8xxx/fdt.c

index e14de9dc960702f270313a360049c42771e67e14..8df9f8e850b5786be5402b2991f7296a61fb0925 100644 (file)
@@ -184,6 +184,35 @@ void set_liodns(void)
 #endif
 }
 
+static void fdt_fixup_srio_liodn(void *blob, struct srio_liodn_id_table *tbl)
+{
+       int i, srio_off;
+
+       /* search for srio node, if doesn't exist just return - nothing todo */
+       srio_off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio");
+       if (srio_off < 0)
+               return ;
+
+       for (i = 0; i < srio_liodn_tbl_sz; i++) {
+               int off, portid = tbl[i].portid;
+
+               off = fdt_node_offset_by_prop_value(blob, srio_off,
+                        "cell-index", &portid, 4);
+               if (off >= 0) {
+                       off = fdt_setprop(blob, off, "fsl,liodn",
+                               &tbl[i].id[0],
+                               sizeof(u32) * tbl[i].num_ids);
+                       if (off > 0)
+                               printf("WARNING unable to set fsl,liodn for "
+                                       "fsl,srio port %d: %s\n",
+                                       portid, fdt_strerror(off));
+               } else {
+                       debug("WARNING: couldn't set fsl,liodn for srio: %s.\n",
+                               fdt_strerror(off));
+               }
+       }
+}
+
 static void fdt_fixup_liodn_tbl(void *blob, struct liodn_id_table *tbl, int sz)
 {
        int i;
@@ -213,6 +242,8 @@ static void fdt_fixup_liodn_tbl(void *blob, struct liodn_id_table *tbl, int sz)
 
 void fdt_fixup_liodn(void *blob)
 {
+       fdt_fixup_srio_liodn(blob, srio_liodn_tbl);
+
        fdt_fixup_liodn_tbl(blob, liodn_tbl, liodn_tbl_sz);
 #ifdef CONFIG_SYS_DPAA_FMAN
        fdt_fixup_liodn_tbl(blob, fman1_liodn_tbl, fman1_liodn_tbl_sz);
index 5bb9f53542299f85cc585a9b482639910014810d..112c60353289d5a29674ad30b81dc0756c65473f 100644 (file)
@@ -275,21 +275,73 @@ int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
 }
 
 #ifdef CONFIG_SYS_SRIO
+static inline void ft_disable_srio_port(void *blob, int srio_off, int port)
+{
+       int off = fdt_node_offset_by_prop_value(blob, srio_off,
+                       "cell-index", &port, 4);
+       if (off >= 0) {
+               off = fdt_setprop_string(blob, off, "status", "disabled");
+               if (off > 0)
+                       printf("WARNING unable to set status for fsl,srio "
+                               "port %d: %s\n", port, fdt_strerror(off));
+       }
+}
+
+static inline void ft_disable_rman(void *blob)
+{
+       int off = fdt_node_offset_by_compatible(blob, -1, "fsl,rman");
+       if (off >= 0) {
+               off = fdt_setprop_string(blob, off, "status", "disabled");
+               if (off > 0)
+                       printf("WARNING unable to set status for fsl,rman %s\n",
+                               fdt_strerror(off));
+       }
+}
+
+static inline void ft_disable_rmu(void *blob)
+{
+       int off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio-rmu");
+       if (off >= 0) {
+               off = fdt_setprop_string(blob, off, "status", "disabled");
+               if (off > 0)
+                       printf("WARNING unable to set status for "
+                               "fsl,srio-rmu %s\n", fdt_strerror(off));
+       }
+}
+
 void ft_srio_setup(void *blob)
 {
+       int srio1_used = 0, srio2_used = 0;
+       int srio_off;
+
+       /* search for srio node, if doesn't exist just return - nothing todo */
+       srio_off = fdt_node_offset_by_compatible(blob, -1, "fsl,srio");
+       if (srio_off < 0)
+               return ;
+
 #ifdef CONFIG_SRIO1
-       if (!is_serdes_configured(SRIO1)) {
-               fdt_del_node_and_alias(blob, "rio0");
-       }
-#else
-       fdt_del_node_and_alias(blob, "rio0");
+       if (is_serdes_configured(SRIO1))
+               srio1_used = 1;
 #endif
 #ifdef CONFIG_SRIO2
-       if (!is_serdes_configured(SRIO2)) {
-               fdt_del_node_and_alias(blob, "rio1");
-       }
-#else
-       fdt_del_node_and_alias(blob, "rio1");
+       if (is_serdes_configured(SRIO2))
+               srio2_used = 1;
 #endif
+
+       /* mark port1 disabled */
+       if (!srio1_used)
+               ft_disable_srio_port(blob, srio_off, 1);
+
+       /* mark port2 disabled */
+       if (!srio2_used)
+               ft_disable_srio_port(blob, srio_off, 2);
+
+       /* if both ports not used, disable controller, rmu and rman */
+       if (!srio1_used && !srio2_used) {
+               fdt_setprop_string(blob, srio_off, "status", "disabled");
+
+               ft_disable_rman(blob);
+               ft_disable_rmu(blob);
+       }
 }
 #endif