rapidio: add Port-Write handling for EM
[firefly-linux-kernel-4.4.55.git] / drivers / rapidio / switches / tsi568.c
index bce9112ff0d95fd423e56ce3b1856fed8997500b..905cf9cb09cca0726d094b2927aa9fda97e140e0 100644 (file)
@@ -25,6 +25,9 @@
 #define SPP_ROUTE_CFG_DESTID(n)        (0x11070 + 0x100*n)
 #define SPP_ROUTE_CFG_PORT(n)  (0x11074 + 0x100*n)
 
+#define TSI568_SP_MODE_BC      0x10004
+#define  TSI568_SP_MODE_PW_DIS 0x08000000
+
 static int
 tsi568_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount,
                       u16 table, u16 route_destid, u8 route_port)
@@ -104,3 +107,24 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
 }
 
 DECLARE_RIO_ROUTE_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_route_add_entry, tsi568_route_get_entry, tsi568_route_clr_table);
+
+static int
+tsi568_em_init(struct rio_dev *rdev)
+{
+       struct rio_mport *mport = rdev->net->hport;
+       u16 destid = rdev->rswitch->destid;
+       u8 hopcount = rdev->rswitch->hopcount;
+       u32 regval;
+
+       pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount);
+
+       /* Make sure that Port-Writes are disabled (for all ports) */
+       rio_mport_read_config_32(mport, destid, hopcount,
+                       TSI568_SP_MODE_BC, &regval);
+       rio_mport_write_config_32(mport, destid, hopcount,
+                       TSI568_SP_MODE_BC, regval | TSI568_SP_MODE_PW_DIS);
+
+       return 0;
+}
+
+DECLARE_RIO_EM_OPS(RIO_VID_TUNDRA, RIO_DID_TSI568, tsi568_em_init, NULL);