]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/rapidio/switches/idtcps.c
Merge branch 'xen/xenbus' into upstream/xen
[karo-tx-linux.git] / drivers / rapidio / switches / idtcps.c
index 46e6630dacd378fe51287ed13bfe329e643cd8d3..2c790c144f8928868e903520c3bf97dabc060c28 100644 (file)
 #include <linux/rio_ids.h>
 #include "../rio.h"
 
-#define CPS_NO_ROUTE 0xdf
+#define CPS_DEFAULT_ROUTE      0xde
+#define CPS_NO_ROUTE           0xdf
+
+#define IDTCPS_RIO_DOMAIN 0xf20020
 
 static int
 idtcps_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
@@ -51,10 +54,11 @@ idtcps_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
                rio_mport_read_config_32(mport, destid, hopcount,
                                RIO_STD_RTE_CONF_PORT_SEL_CSR, &result);
 
-               if (CPS_NO_ROUTE == (u8)result)
-                       result = RIO_INVALID_ROUTE;
-
-               *route_port = (u8)result;
+               if (CPS_DEFAULT_ROUTE == (u8)result ||
+                   CPS_NO_ROUTE == (u8)result)
+                       *route_port = RIO_INVALID_ROUTE;
+               else
+                       *route_port = (u8)result;
        }
 
        return 0;
@@ -72,9 +76,9 @@ idtcps_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
                                RIO_STD_RTE_CONF_DESTID_SEL_CSR, i);
                        rio_mport_write_config_32(mport, destid, hopcount,
                                RIO_STD_RTE_CONF_PORT_SEL_CSR,
-                               (RIO_INVALID_ROUTE << 24) |
-                               (RIO_INVALID_ROUTE << 16) |
-                               (RIO_INVALID_ROUTE << 8) | RIO_INVALID_ROUTE);
+                               (CPS_DEFAULT_ROUTE << 24) |
+                               (CPS_DEFAULT_ROUTE << 16) |
+                               (CPS_DEFAULT_ROUTE << 8) | CPS_DEFAULT_ROUTE);
                        i += 4;
                }
        }
@@ -82,12 +86,43 @@ idtcps_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
        return 0;
 }
 
+static int
+idtcps_set_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
+                      u8 sw_domain)
+{
+       /*
+        * Switch domain configuration operates only at global level
+        */
+       rio_mport_write_config_32(mport, destid, hopcount,
+                                 IDTCPS_RIO_DOMAIN, (u32)sw_domain);
+       return 0;
+}
+
+static int
+idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
+                      u8 *sw_domain)
+{
+       u32 regval;
+
+       /*
+        * Switch domain configuration operates only at global level
+        */
+       rio_mport_read_config_32(mport, destid, hopcount,
+                               IDTCPS_RIO_DOMAIN, &regval);
+
+       *sw_domain = (u8)(regval & 0xff);
+
+       return 0;
+}
+
 static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
 {
        pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
        rdev->rswitch->add_entry = idtcps_route_add_entry;
        rdev->rswitch->get_entry = idtcps_route_get_entry;
        rdev->rswitch->clr_table = idtcps_route_clr_table;
+       rdev->rswitch->set_domain = idtcps_set_domain;
+       rdev->rswitch->get_domain = idtcps_get_domain;
        rdev->rswitch->em_init = NULL;
        rdev->rswitch->em_handle = NULL;