aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2011-01-12 20:00:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:17 -0500
commita93192a5d245a262dc52fa426de5b20467308a77 (patch)
treef3231240286ef3d204375e047f6b2e1a8efbbcd2 /drivers
parente6d7202b66d99bf514c8e901db68386b1fcd6d56 (diff)
rapidio: use common destid storage for endpoints and switches
Change code to use one storage location common for switches and endpoints. This eliminates unnecessary device type checks during basic access operations. Logic that assigns destid to RIO devices stays unchanged - as before, switches use an associated destid because they do not have their own. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Cc: Thomas Moll <thomas.moll@sysgo.com> Cc: Micha Nelissen <micha@neli.hopto.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rapidio/rio-scan.c84
-rw-r--r--drivers/rapidio/rio.c74
-rw-r--r--drivers/rapidio/switches/idt_gen2.c93
-rw-r--r--drivers/rapidio/switches/idtcps.c6
-rw-r--r--drivers/rapidio/switches/tsi568.c13
-rw-r--r--drivers/rapidio/switches/tsi57x.c56
6 files changed, 126 insertions, 200 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 1eb82c4c712e..51f0af241eb7 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -437,9 +437,15 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
437 next_destid++; 437 next_destid++;
438 } else 438 } else
439 rdev->destid = rio_get_device_id(port, destid, hopcount); 439 rdev->destid = rio_get_device_id(port, destid, hopcount);
440 } else 440
441 /* Switch device has an associated destID */ 441 rdev->hopcount = 0xff;
442 rdev->destid = RIO_INVALID_DESTID; 442 } else {
443 /* Switch device has an associated destID which
444 * will be adjusted later
445 */
446 rdev->destid = destid;
447 rdev->hopcount = hopcount;
448 }
443 449
444 /* If a PE has both switch and other functions, show it as a switch */ 450 /* If a PE has both switch and other functions, show it as a switch */
445 if (rio_is_switch(rdev)) { 451 if (rio_is_switch(rdev)) {
@@ -450,8 +456,6 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net,
450 if (!rswitch) 456 if (!rswitch)
451 goto cleanup; 457 goto cleanup;
452 rswitch->switchid = next_switchid; 458 rswitch->switchid = next_switchid;
453 rswitch->hopcount = hopcount;
454 rswitch->destid = destid;
455 rswitch->port_ok = 0; 459 rswitch->port_ok = 0;
456 rswitch->route_table = kzalloc(sizeof(u8)* 460 rswitch->route_table = kzalloc(sizeof(u8)*
457 RIO_MAX_ROUTE_ENTRIES(port->sys_size), 461 RIO_MAX_ROUTE_ENTRIES(port->sys_size),
@@ -632,8 +636,7 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount)
632 636
633/** 637/**
634 * rio_route_add_entry- Add a route entry to a switch routing table 638 * rio_route_add_entry- Add a route entry to a switch routing table
635 * @mport: Master port to send transaction 639 * @rdev: RIO device
636 * @rswitch: Switch device
637 * @table: Routing table ID 640 * @table: Routing table ID
638 * @route_destid: Destination ID to be routed 641 * @route_destid: Destination ID to be routed
639 * @route_port: Port number to be routed 642 * @route_port: Port number to be routed
@@ -647,31 +650,31 @@ rio_unlock_device(struct rio_mport *port, u16 destid, u8 hopcount)
647 * on failure. 650 * on failure.
648 */ 651 */
649static int 652static int
650rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch, 653rio_route_add_entry(struct rio_dev *rdev,
651 u16 table, u16 route_destid, u8 route_port, int lock) 654 u16 table, u16 route_destid, u8 route_port, int lock)
652{ 655{
653 int rc; 656 int rc;
654 657
655 if (lock) { 658 if (lock) {
656 rc = rio_lock_device(mport, rswitch->destid, 659 rc = rio_lock_device(rdev->net->hport, rdev->destid,
657 rswitch->hopcount, 1000); 660 rdev->hopcount, 1000);
658 if (rc) 661 if (rc)
659 return rc; 662 return rc;
660 } 663 }
661 664
662 rc = rswitch->add_entry(mport, rswitch->destid, 665 rc = rdev->rswitch->add_entry(rdev->net->hport, rdev->destid,
663 rswitch->hopcount, table, 666 rdev->hopcount, table,
664 route_destid, route_port); 667 route_destid, route_port);
665 if (lock) 668 if (lock)
666 rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); 669 rio_unlock_device(rdev->net->hport, rdev->destid,
670 rdev->hopcount);
667 671
668 return rc; 672 return rc;
669} 673}
670 674
671/** 675/**
672 * rio_route_get_entry- Read a route entry in a switch routing table 676 * rio_route_get_entry- Read a route entry in a switch routing table
673 * @mport: Master port to send transaction 677 * @rdev: RIO device
674 * @rswitch: Switch device
675 * @table: Routing table ID 678 * @table: Routing table ID
676 * @route_destid: Destination ID to be routed 679 * @route_destid: Destination ID to be routed
677 * @route_port: Pointer to read port number into 680 * @route_port: Pointer to read port number into
@@ -685,23 +688,24 @@ rio_route_add_entry(struct rio_mport *mport, struct rio_switch *rswitch,
685 * on failure. 688 * on failure.
686 */ 689 */
687static int 690static int
688rio_route_get_entry(struct rio_mport *mport, struct rio_switch *rswitch, u16 table, 691rio_route_get_entry(struct rio_dev *rdev, u16 table,
689 u16 route_destid, u8 *route_port, int lock) 692 u16 route_destid, u8 *route_port, int lock)
690{ 693{
691 int rc; 694 int rc;
692 695
693 if (lock) { 696 if (lock) {
694 rc = rio_lock_device(mport, rswitch->destid, 697 rc = rio_lock_device(rdev->net->hport, rdev->destid,
695 rswitch->hopcount, 1000); 698 rdev->hopcount, 1000);
696 if (rc) 699 if (rc)
697 return rc; 700 return rc;
698 } 701 }
699 702
700 rc = rswitch->get_entry(mport, rswitch->destid, 703 rc = rdev->rswitch->get_entry(rdev->net->hport, rdev->destid,
701 rswitch->hopcount, table, 704 rdev->hopcount, table,
702 route_destid, route_port); 705 route_destid, route_port);
703 if (lock) 706 if (lock)
704 rio_unlock_device(mport, rswitch->destid, rswitch->hopcount); 707 rio_unlock_device(rdev->net->hport, rdev->destid,
708 rdev->hopcount);
705 709
706 return rc; 710 return rc;
707} 711}
@@ -811,14 +815,14 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
811 if (rio_is_switch(rdev)) { 815 if (rio_is_switch(rdev)) {
812 next_switchid++; 816 next_switchid++;
813 sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); 817 sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo);
814 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, 818 rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
815 port->host_deviceid, sw_inport, 0); 819 port->host_deviceid, sw_inport, 0);
816 rdev->rswitch->route_table[port->host_deviceid] = sw_inport; 820 rdev->rswitch->route_table[port->host_deviceid] = sw_inport;
817 821
818 for (destid = 0; destid < next_destid; destid++) { 822 for (destid = 0; destid < next_destid; destid++) {
819 if (destid == port->host_deviceid) 823 if (destid == port->host_deviceid)
820 continue; 824 continue;
821 rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, 825 rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
822 destid, sw_inport, 0); 826 destid, sw_inport, 0);
823 rdev->rswitch->route_table[destid] = sw_inport; 827 rdev->rswitch->route_table[destid] = sw_inport;
824 } 828 }
@@ -850,8 +854,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
850 "RIO: scanning device on port %d\n", 854 "RIO: scanning device on port %d\n",
851 port_num); 855 port_num);
852 rdev->rswitch->port_ok |= (1 << port_num); 856 rdev->rswitch->port_ok |= (1 << port_num);
853 rio_route_add_entry(port, rdev->rswitch, 857 rio_route_add_entry(rdev, RIO_GLOBAL_TABLE,
854 RIO_GLOBAL_TABLE,
855 RIO_ANY_DESTID(port->sys_size), 858 RIO_ANY_DESTID(port->sys_size),
856 port_num, 0); 859 port_num, 0);
857 860
@@ -865,7 +868,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
865 destid < next_destid; destid++) { 868 destid < next_destid; destid++) {
866 if (destid == port->host_deviceid) 869 if (destid == port->host_deviceid)
867 continue; 870 continue;
868 rio_route_add_entry(port, rdev->rswitch, 871 rio_route_add_entry(rdev,
869 RIO_GLOBAL_TABLE, 872 RIO_GLOBAL_TABLE,
870 destid, 873 destid,
871 port_num, 874 port_num,
@@ -904,7 +907,7 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port,
904 next_destid++; 907 next_destid++;
905 } 908 }
906 909
907 rdev->rswitch->destid = sw_destid; 910 rdev->destid = sw_destid;
908 } else 911 } else
909 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n", 912 pr_debug("RIO: found %s (vid %4.4x did %4.4x)\n",
910 rio_name(rdev), rdev->vid, rdev->did); 913 rio_name(rdev), rdev->vid, rdev->did);
@@ -958,7 +961,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
958 next_switchid++; 961 next_switchid++;
959 962
960 /* Associated destid is how we accessed this switch */ 963 /* Associated destid is how we accessed this switch */
961 rdev->rswitch->destid = destid; 964 rdev->destid = destid;
962 965
963 pr_debug( 966 pr_debug(
964 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", 967 "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n",
@@ -981,7 +984,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
981 for (ndestid = 0; 984 for (ndestid = 0;
982 ndestid < RIO_ANY_DESTID(port->sys_size); 985 ndestid < RIO_ANY_DESTID(port->sys_size);
983 ndestid++) { 986 ndestid++) {
984 rio_route_get_entry(port, rdev->rswitch, 987 rio_route_get_entry(rdev,
985 RIO_GLOBAL_TABLE, 988 RIO_GLOBAL_TABLE,
986 ndestid, 989 ndestid,
987 &route_port, 0); 990 &route_port, 0);
@@ -1076,7 +1079,7 @@ static void rio_update_route_tables(struct rio_mport *port)
1076 1079
1077 list_for_each_entry(rdev, &rio_devices, global_list) { 1080 list_for_each_entry(rdev, &rio_devices, global_list) {
1078 1081
1079 destid = (rio_is_switch(rdev))?rdev->rswitch->destid:rdev->destid; 1082 destid = rdev->destid;
1080 1083
1081 list_for_each_entry(rswitch, &rio_switches, node) { 1084 list_for_each_entry(rswitch, &rio_switches, node) {
1082 1085
@@ -1085,13 +1088,13 @@ static void rio_update_route_tables(struct rio_mport *port)
1085 1088
1086 if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) { 1089 if (RIO_INVALID_ROUTE == rswitch->route_table[destid]) {
1087 /* Skip if destid ends in empty switch*/ 1090 /* Skip if destid ends in empty switch*/
1088 if (rswitch->destid == destid) 1091 if (rswitch->rdev->destid == destid)
1089 continue; 1092 continue;
1090 1093
1091 sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo); 1094 sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo);
1092 1095
1093 if (rswitch->add_entry) { 1096 if (rswitch->add_entry) {
1094 rio_route_add_entry(port, rswitch, 1097 rio_route_add_entry(rswitch->rdev,
1095 RIO_GLOBAL_TABLE, destid, 1098 RIO_GLOBAL_TABLE, destid,
1096 sport, 0); 1099 sport, 0);
1097 rswitch->route_table[destid] = sport; 1100 rswitch->route_table[destid] = sport;
@@ -1203,21 +1206,20 @@ static void rio_build_route_tables(void)
1203 1206
1204 list_for_each_entry(rdev, &rio_devices, global_list) 1207 list_for_each_entry(rdev, &rio_devices, global_list)
1205 if (rio_is_switch(rdev)) { 1208 if (rio_is_switch(rdev)) {
1206 rio_lock_device(rdev->net->hport, rdev->rswitch->destid, 1209 rio_lock_device(rdev->net->hport, rdev->destid,
1207 rdev->rswitch->hopcount, 1000); 1210 rdev->hopcount, 1000);
1208 for (i = 0; 1211 for (i = 0;
1209 i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); 1212 i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size);
1210 i++) { 1213 i++) {
1211 if (rio_route_get_entry 1214 if (rio_route_get_entry(rdev,
1212 (rdev->net->hport, rdev->rswitch, 1215 RIO_GLOBAL_TABLE, i, &sport, 0) < 0)
1213 RIO_GLOBAL_TABLE, i, &sport, 0) < 0)
1214 continue; 1216 continue;
1215 rdev->rswitch->route_table[i] = sport; 1217 rdev->rswitch->route_table[i] = sport;
1216 } 1218 }
1217 1219
1218 rio_unlock_device(rdev->net->hport, 1220 rio_unlock_device(rdev->net->hport,
1219 rdev->rswitch->destid, 1221 rdev->destid,
1220 rdev->rswitch->hopcount); 1222 rdev->hopcount);
1221 } 1223 }
1222} 1224}
1223 1225
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 7b5080c45569..c13289e10bb1 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -471,16 +471,9 @@ exit:
471 */ 471 */
472int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) 472int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock)
473{ 473{
474 u8 hopcount = 0xff;
475 u16 destid = rdev->destid;
476 u32 regval; 474 u32 regval;
477 475
478 if (rdev->rswitch) { 476 rio_read_config_32(rdev,
479 destid = rdev->rswitch->destid;
480 hopcount = rdev->rswitch->hopcount;
481 }
482
483 rio_mport_read_config_32(rdev->net->hport, destid, hopcount,
484 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum), 477 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
485 &regval); 478 &regval);
486 if (lock) 479 if (lock)
@@ -488,7 +481,7 @@ int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock)
488 else 481 else
489 regval &= ~RIO_PORT_N_CTL_LOCKOUT; 482 regval &= ~RIO_PORT_N_CTL_LOCKOUT;
490 483
491 rio_mport_write_config_32(rdev->net->hport, destid, hopcount, 484 rio_write_config_32(rdev,
492 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum), 485 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(pnum),
493 regval); 486 regval);
494 return 0; 487 return 0;
@@ -507,7 +500,7 @@ static int
507rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) 500rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum)
508{ 501{
509 u32 result; 502 u32 result;
510 int p_port, dstid, rc = -EIO; 503 int p_port, rc = -EIO;
511 struct rio_dev *prev = NULL; 504 struct rio_dev *prev = NULL;
512 505
513 /* Find switch with failed RIO link */ 506 /* Find switch with failed RIO link */
@@ -522,9 +515,7 @@ rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum)
522 if (prev == NULL) 515 if (prev == NULL)
523 goto err_out; 516 goto err_out;
524 517
525 dstid = (rdev->pef & RIO_PEF_SWITCH) ? 518 p_port = prev->rswitch->route_table[rdev->destid];
526 rdev->rswitch->destid : rdev->destid;
527 p_port = prev->rswitch->route_table[dstid];
528 519
529 if (p_port != RIO_INVALID_ROUTE) { 520 if (p_port != RIO_INVALID_ROUTE) {
530 pr_debug("RIO: link failed on [%s]-P%d\n", 521 pr_debug("RIO: link failed on [%s]-P%d\n",
@@ -567,15 +558,8 @@ rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, u8 hopcount)
567 */ 558 */
568static int rio_chk_dev_access(struct rio_dev *rdev) 559static int rio_chk_dev_access(struct rio_dev *rdev)
569{ 560{
570 u8 hopcount = 0xff; 561 return rio_mport_chk_dev_access(rdev->net->hport,
571 u16 destid = rdev->destid; 562 rdev->destid, rdev->hopcount);
572
573 if (rdev->rswitch) {
574 destid = rdev->rswitch->destid;
575 hopcount = rdev->rswitch->hopcount;
576 }
577
578 return rio_mport_chk_dev_access(rdev->net->hport, destid, hopcount);
579} 563}
580 564
581/** 565/**
@@ -588,23 +572,20 @@ static int rio_chk_dev_access(struct rio_dev *rdev)
588static int 572static int
589rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) 573rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
590{ 574{
591 struct rio_mport *mport = rdev->net->hport;
592 u16 destid = rdev->rswitch->destid;
593 u8 hopcount = rdev->rswitch->hopcount;
594 u32 regval; 575 u32 regval;
595 int checkcount; 576 int checkcount;
596 577
597 if (lnkresp) { 578 if (lnkresp) {
598 /* Read from link maintenance response register 579 /* Read from link maintenance response register
599 * to clear valid bit */ 580 * to clear valid bit */
600 rio_mport_read_config_32(mport, destid, hopcount, 581 rio_read_config_32(rdev,
601 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), 582 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum),
602 &regval); 583 &regval);
603 udelay(50); 584 udelay(50);
604 } 585 }
605 586
606 /* Issue Input-status command */ 587 /* Issue Input-status command */
607 rio_mport_write_config_32(mport, destid, hopcount, 588 rio_write_config_32(rdev,
608 rdev->phys_efptr + RIO_PORT_N_MNT_REQ_CSR(pnum), 589 rdev->phys_efptr + RIO_PORT_N_MNT_REQ_CSR(pnum),
609 RIO_MNT_REQ_CMD_IS); 590 RIO_MNT_REQ_CMD_IS);
610 591
@@ -615,7 +596,7 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
615 checkcount = 3; 596 checkcount = 3;
616 while (checkcount--) { 597 while (checkcount--) {
617 udelay(50); 598 udelay(50);
618 rio_mport_read_config_32(mport, destid, hopcount, 599 rio_read_config_32(rdev,
619 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), 600 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum),
620 &regval); 601 &regval);
621 if (regval & RIO_PORT_N_MNT_RSP_RVAL) { 602 if (regval & RIO_PORT_N_MNT_RSP_RVAL) {
@@ -635,15 +616,12 @@ rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp)
635 */ 616 */
636static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) 617static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
637{ 618{
638 struct rio_mport *mport = rdev->net->hport;
639 u16 destid = rdev->rswitch->destid;
640 u8 hopcount = rdev->rswitch->hopcount;
641 struct rio_dev *nextdev = rdev->rswitch->nextdev[pnum]; 619 struct rio_dev *nextdev = rdev->rswitch->nextdev[pnum];
642 u32 regval; 620 u32 regval;
643 u32 far_ackid, far_linkstat, near_ackid; 621 u32 far_ackid, far_linkstat, near_ackid;
644 622
645 if (err_status == 0) 623 if (err_status == 0)
646 rio_mport_read_config_32(mport, destid, hopcount, 624 rio_read_config_32(rdev,
647 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), 625 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
648 &err_status); 626 &err_status);
649 627
@@ -661,7 +639,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
661 pnum, regval); 639 pnum, regval);
662 far_ackid = (regval & RIO_PORT_N_MNT_RSP_ASTAT) >> 5; 640 far_ackid = (regval & RIO_PORT_N_MNT_RSP_ASTAT) >> 5;
663 far_linkstat = regval & RIO_PORT_N_MNT_RSP_LSTAT; 641 far_linkstat = regval & RIO_PORT_N_MNT_RSP_LSTAT;
664 rio_mport_read_config_32(mport, destid, hopcount, 642 rio_read_config_32(rdev,
665 rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum), 643 rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum),
666 &regval); 644 &regval);
667 pr_debug("RIO_EM: SP%d_ACK_STS_CSR=0x%08x\n", pnum, regval); 645 pr_debug("RIO_EM: SP%d_ACK_STS_CSR=0x%08x\n", pnum, regval);
@@ -679,9 +657,8 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
679 /* Align near outstanding/outbound ackIDs with 657 /* Align near outstanding/outbound ackIDs with
680 * far inbound. 658 * far inbound.
681 */ 659 */
682 rio_mport_write_config_32(mport, destid, 660 rio_write_config_32(rdev,
683 hopcount, rdev->phys_efptr + 661 rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum),
684 RIO_PORT_N_ACK_STS_CSR(pnum),
685 (near_ackid << 24) | 662 (near_ackid << 24) |
686 (far_ackid << 8) | far_ackid); 663 (far_ackid << 8) | far_ackid);
687 /* Align far outstanding/outbound ackIDs with 664 /* Align far outstanding/outbound ackIDs with
@@ -698,7 +675,7 @@ static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status)
698 pr_debug("RIO_EM: Invalid nextdev pointer (NULL)\n"); 675 pr_debug("RIO_EM: Invalid nextdev pointer (NULL)\n");
699 } 676 }
700rd_err: 677rd_err:
701 rio_mport_read_config_32(mport, destid, hopcount, 678 rio_read_config_32(rdev,
702 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), 679 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
703 &err_status); 680 &err_status);
704 pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); 681 pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status);
@@ -710,7 +687,7 @@ rd_err:
710 RIO_GET_PORT_NUM(nextdev->swpinfo), NULL); 687 RIO_GET_PORT_NUM(nextdev->swpinfo), NULL);
711 udelay(50); 688 udelay(50);
712 689
713 rio_mport_read_config_32(mport, destid, hopcount, 690 rio_read_config_32(rdev,
714 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), 691 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum),
715 &err_status); 692 &err_status);
716 pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); 693 pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status);
@@ -730,9 +707,6 @@ rd_err:
730int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) 707int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
731{ 708{
732 struct rio_dev *rdev; 709 struct rio_dev *rdev;
733 struct rio_mport *mport;
734 u8 hopcount;
735 u16 destid;
736 u32 err_status, em_perrdet, em_ltlerrdet; 710 u32 err_status, em_perrdet, em_ltlerrdet;
737 int rc, portnum; 711 int rc, portnum;
738 712
@@ -800,17 +774,13 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
800 return 0; 774 return 0;
801 } 775 }
802 776
803 mport = rdev->net->hport;
804 destid = rdev->rswitch->destid;
805 hopcount = rdev->rswitch->hopcount;
806
807 /* 777 /*
808 * Process the port-write notification from switch 778 * Process the port-write notification from switch
809 */ 779 */
810 if (rdev->rswitch->em_handle) 780 if (rdev->rswitch->em_handle)
811 rdev->rswitch->em_handle(rdev, portnum); 781 rdev->rswitch->em_handle(rdev, portnum);
812 782
813 rio_mport_read_config_32(mport, destid, hopcount, 783 rio_read_config_32(rdev,
814 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), 784 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
815 &err_status); 785 &err_status);
816 pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status); 786 pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status);
@@ -840,7 +810,7 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
840 rdev->rswitch->port_ok &= ~(1 << portnum); 810 rdev->rswitch->port_ok &= ~(1 << portnum);
841 rio_set_port_lockout(rdev, portnum, 1); 811 rio_set_port_lockout(rdev, portnum, 1);
842 812
843 rio_mport_write_config_32(mport, destid, hopcount, 813 rio_write_config_32(rdev,
844 rdev->phys_efptr + 814 rdev->phys_efptr +
845 RIO_PORT_N_ACK_STS_CSR(portnum), 815 RIO_PORT_N_ACK_STS_CSR(portnum),
846 RIO_PORT_N_ACK_CLEAR); 816 RIO_PORT_N_ACK_CLEAR);
@@ -851,28 +821,28 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg)
851 } 821 }
852 } 822 }
853 823
854 rio_mport_read_config_32(mport, destid, hopcount, 824 rio_read_config_32(rdev,
855 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); 825 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet);
856 if (em_perrdet) { 826 if (em_perrdet) {
857 pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n", 827 pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n",
858 portnum, em_perrdet); 828 portnum, em_perrdet);
859 /* Clear EM Port N Error Detect CSR */ 829 /* Clear EM Port N Error Detect CSR */
860 rio_mport_write_config_32(mport, destid, hopcount, 830 rio_write_config_32(rdev,
861 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0); 831 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0);
862 } 832 }
863 833
864 rio_mport_read_config_32(mport, destid, hopcount, 834 rio_read_config_32(rdev,
865 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); 835 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet);
866 if (em_ltlerrdet) { 836 if (em_ltlerrdet) {
867 pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n", 837 pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n",
868 em_ltlerrdet); 838 em_ltlerrdet);
869 /* Clear EM L/T Layer Error Detect CSR */ 839 /* Clear EM L/T Layer Error Detect CSR */
870 rio_mport_write_config_32(mport, destid, hopcount, 840 rio_write_config_32(rdev,
871 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0); 841 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0);
872 } 842 }
873 843
874 /* Clear remaining error bits and Port-Write Pending bit */ 844 /* Clear remaining error bits and Port-Write Pending bit */
875 rio_mport_write_config_32(mport, destid, hopcount, 845 rio_write_config_32(rdev,
876 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), 846 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
877 err_status); 847 err_status);
878 848
diff --git a/drivers/rapidio/switches/idt_gen2.c b/drivers/rapidio/switches/idt_gen2.c
index 0bb871cb5c40..dd4b2b7112c0 100644
--- a/drivers/rapidio/switches/idt_gen2.c
+++ b/drivers/rapidio/switches/idt_gen2.c
@@ -209,9 +209,6 @@ idtg2_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
209static int 209static int
210idtg2_em_init(struct rio_dev *rdev) 210idtg2_em_init(struct rio_dev *rdev)
211{ 211{
212 struct rio_mport *mport = rdev->net->hport;
213 u16 destid = rdev->rswitch->destid;
214 u8 hopcount = rdev->rswitch->hopcount;
215 u32 regval; 212 u32 regval;
216 int i, tmp; 213 int i, tmp;
217 214
@@ -220,29 +217,25 @@ idtg2_em_init(struct rio_dev *rdev)
220 * All standard EM configuration should be performed at upper level. 217 * All standard EM configuration should be performed at upper level.
221 */ 218 */
222 219
223 pr_debug("RIO: %s [%d:%d]\n", __func__, destid, hopcount); 220 pr_debug("RIO: %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
224 221
225 /* Set Port-Write info CSR: PRIO=3 and CRF=1 */ 222 /* Set Port-Write info CSR: PRIO=3 and CRF=1 */
226 rio_mport_write_config_32(mport, destid, hopcount, 223 rio_write_config_32(rdev, IDT_PW_INFO_CSR, 0x0000e000);
227 IDT_PW_INFO_CSR, 0x0000e000);
228 224
229 /* 225 /*
230 * Configure LT LAYER error reporting. 226 * Configure LT LAYER error reporting.
231 */ 227 */
232 228
233 /* Enable standard (RIO.p8) error reporting */ 229 /* Enable standard (RIO.p8) error reporting */
234 rio_mport_write_config_32(mport, destid, hopcount, 230 rio_write_config_32(rdev, IDT_LT_ERR_REPORT_EN,
235 IDT_LT_ERR_REPORT_EN,
236 REM_LTL_ERR_ILLTRAN | REM_LTL_ERR_UNSOLR | 231 REM_LTL_ERR_ILLTRAN | REM_LTL_ERR_UNSOLR |
237 REM_LTL_ERR_UNSUPTR); 232 REM_LTL_ERR_UNSUPTR);
238 233
239 /* Use Port-Writes for LT layer error reporting. 234 /* Use Port-Writes for LT layer error reporting.
240 * Enable per-port reset 235 * Enable per-port reset
241 */ 236 */
242 rio_mport_read_config_32(mport, destid, hopcount, 237 rio_read_config_32(rdev, IDT_DEV_CTRL_1, &regval);
243 IDT_DEV_CTRL_1, &regval); 238 rio_write_config_32(rdev, IDT_DEV_CTRL_1,
244 rio_mport_write_config_32(mport, destid, hopcount,
245 IDT_DEV_CTRL_1,
246 regval | IDT_DEV_CTRL_1_GENPW | IDT_DEV_CTRL_1_PRSTBEH); 239 regval | IDT_DEV_CTRL_1_GENPW | IDT_DEV_CTRL_1_PRSTBEH);
247 240
248 /* 241 /*
@@ -250,45 +243,40 @@ idtg2_em_init(struct rio_dev *rdev)
250 */ 243 */
251 244
252 /* Report all RIO.p8 errors supported by device */ 245 /* Report all RIO.p8 errors supported by device */
253 rio_mport_write_config_32(mport, destid, hopcount, 246 rio_write_config_32(rdev, IDT_PORT_ERR_REPORT_EN_BC, 0x807e8037);
254 IDT_PORT_ERR_REPORT_EN_BC, 0x807e8037);
255 247
256 /* Configure reporting of implementation specific errors/events */ 248 /* Configure reporting of implementation specific errors/events */
257 rio_mport_write_config_32(mport, destid, hopcount, 249 rio_write_config_32(rdev, IDT_PORT_ISERR_REPORT_EN_BC,
258 IDT_PORT_ISERR_REPORT_EN_BC, IDT_PORT_INIT_TX_ACQUIRED); 250 IDT_PORT_INIT_TX_ACQUIRED);
259 251
260 /* Use Port-Writes for port error reporting and enable error logging */ 252 /* Use Port-Writes for port error reporting and enable error logging */
261 tmp = RIO_GET_TOTAL_PORTS(rdev->swpinfo); 253 tmp = RIO_GET_TOTAL_PORTS(rdev->swpinfo);
262 for (i = 0; i < tmp; i++) { 254 for (i = 0; i < tmp; i++) {
263 rio_mport_read_config_32(mport, destid, hopcount, 255 rio_read_config_32(rdev, IDT_PORT_OPS(i), &regval);
264 IDT_PORT_OPS(i), &regval); 256 rio_write_config_32(rdev,
265 rio_mport_write_config_32(mport, destid, hopcount,
266 IDT_PORT_OPS(i), regval | IDT_PORT_OPS_GENPW | 257 IDT_PORT_OPS(i), regval | IDT_PORT_OPS_GENPW |
267 IDT_PORT_OPS_PL_ELOG | 258 IDT_PORT_OPS_PL_ELOG |
268 IDT_PORT_OPS_LL_ELOG | 259 IDT_PORT_OPS_LL_ELOG |
269 IDT_PORT_OPS_LT_ELOG); 260 IDT_PORT_OPS_LT_ELOG);
270 } 261 }
271 /* Overwrite error log if full */ 262 /* Overwrite error log if full */
272 rio_mport_write_config_32(mport, destid, hopcount, 263 rio_write_config_32(rdev, IDT_ERR_CAP, IDT_ERR_CAP_LOG_OVERWR);
273 IDT_ERR_CAP, IDT_ERR_CAP_LOG_OVERWR);
274 264
275 /* 265 /*
276 * Configure LANE error reporting. 266 * Configure LANE error reporting.
277 */ 267 */
278 268
279 /* Disable line error reporting */ 269 /* Disable line error reporting */
280 rio_mport_write_config_32(mport, destid, hopcount, 270 rio_write_config_32(rdev, IDT_LANE_ERR_REPORT_EN_BC, 0);
281 IDT_LANE_ERR_REPORT_EN_BC, 0);
282 271
283 /* Use Port-Writes for lane error reporting (when enabled) 272 /* Use Port-Writes for lane error reporting (when enabled)
284 * (do per-lane update because lanes may have different configuration) 273 * (do per-lane update because lanes may have different configuration)
285 */ 274 */
286 tmp = (rdev->did == RIO_DID_IDTCPS1848) ? 48 : 16; 275 tmp = (rdev->did == RIO_DID_IDTCPS1848) ? 48 : 16;
287 for (i = 0; i < tmp; i++) { 276 for (i = 0; i < tmp; i++) {
288 rio_mport_read_config_32(mport, destid, hopcount, 277 rio_read_config_32(rdev, IDT_LANE_CTRL(i), &regval);
289 IDT_LANE_CTRL(i), &regval); 278 rio_write_config_32(rdev, IDT_LANE_CTRL(i),
290 rio_mport_write_config_32(mport, destid, hopcount, 279 regval | IDT_LANE_CTRL_GENPW);
291 IDT_LANE_CTRL(i), regval | IDT_LANE_CTRL_GENPW);
292 } 280 }
293 281
294 /* 282 /*
@@ -296,41 +284,32 @@ idtg2_em_init(struct rio_dev *rdev)
296 */ 284 */
297 285
298 /* Disable JTAG and I2C Error capture */ 286 /* Disable JTAG and I2C Error capture */
299 rio_mport_write_config_32(mport, destid, hopcount, 287 rio_write_config_32(rdev, IDT_AUX_PORT_ERR_CAP_EN, 0);
300 IDT_AUX_PORT_ERR_CAP_EN, 0);
301 288
302 /* Disable JTAG and I2C Error reporting/logging */ 289 /* Disable JTAG and I2C Error reporting/logging */
303 rio_mport_write_config_32(mport, destid, hopcount, 290 rio_write_config_32(rdev, IDT_AUX_ERR_REPORT_EN, 0);
304 IDT_AUX_ERR_REPORT_EN, 0);
305 291
306 /* Disable Port-Write notification from JTAG */ 292 /* Disable Port-Write notification from JTAG */
307 rio_mport_write_config_32(mport, destid, hopcount, 293 rio_write_config_32(rdev, IDT_JTAG_CTRL, 0);
308 IDT_JTAG_CTRL, 0);
309 294
310 /* Disable Port-Write notification from I2C */ 295 /* Disable Port-Write notification from I2C */
311 rio_mport_read_config_32(mport, destid, hopcount, 296 rio_read_config_32(rdev, IDT_I2C_MCTRL, &regval);
312 IDT_I2C_MCTRL, &regval); 297 rio_write_config_32(rdev, IDT_I2C_MCTRL, regval & ~IDT_I2C_MCTRL_GENPW);
313 rio_mport_write_config_32(mport, destid, hopcount,
314 IDT_I2C_MCTRL,
315 regval & ~IDT_I2C_MCTRL_GENPW);
316 298
317 /* 299 /*
318 * Configure CFG_BLK error reporting. 300 * Configure CFG_BLK error reporting.
319 */ 301 */
320 302
321 /* Disable Configuration Block error capture */ 303 /* Disable Configuration Block error capture */
322 rio_mport_write_config_32(mport, destid, hopcount, 304 rio_write_config_32(rdev, IDT_CFGBLK_ERR_CAPTURE_EN, 0);
323 IDT_CFGBLK_ERR_CAPTURE_EN, 0);
324 305
325 /* Disable Port-Writes for Configuration Block error reporting */ 306 /* Disable Port-Writes for Configuration Block error reporting */
326 rio_mport_read_config_32(mport, destid, hopcount, 307 rio_read_config_32(rdev, IDT_CFGBLK_ERR_REPORT, &regval);
327 IDT_CFGBLK_ERR_REPORT, &regval); 308 rio_write_config_32(rdev, IDT_CFGBLK_ERR_REPORT,
328 rio_mport_write_config_32(mport, destid, hopcount, 309 regval & ~IDT_CFGBLK_ERR_REPORT_GENPW);
329 IDT_CFGBLK_ERR_REPORT,
330 regval & ~IDT_CFGBLK_ERR_REPORT_GENPW);
331 310
332 /* set TVAL = ~50us */ 311 /* set TVAL = ~50us */
333 rio_mport_write_config_32(mport, destid, hopcount, 312 rio_write_config_32(rdev,
334 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); 313 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8);
335 314
336 return 0; 315 return 0;
@@ -339,18 +318,15 @@ idtg2_em_init(struct rio_dev *rdev)
339static int 318static int
340idtg2_em_handler(struct rio_dev *rdev, u8 portnum) 319idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
341{ 320{
342 struct rio_mport *mport = rdev->net->hport;
343 u16 destid = rdev->rswitch->destid;
344 u8 hopcount = rdev->rswitch->hopcount;
345 u32 regval, em_perrdet, em_ltlerrdet; 321 u32 regval, em_perrdet, em_ltlerrdet;
346 322
347 rio_mport_read_config_32(mport, destid, hopcount, 323 rio_read_config_32(rdev,
348 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); 324 rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet);
349 if (em_ltlerrdet) { 325 if (em_ltlerrdet) {
350 /* Service Logical/Transport Layer Error(s) */ 326 /* Service Logical/Transport Layer Error(s) */
351 if (em_ltlerrdet & REM_LTL_ERR_IMPSPEC) { 327 if (em_ltlerrdet & REM_LTL_ERR_IMPSPEC) {
352 /* Implementation specific error reported */ 328 /* Implementation specific error reported */
353 rio_mport_read_config_32(mport, destid, hopcount, 329 rio_read_config_32(rdev,
354 IDT_ISLTL_ADDRESS_CAP, &regval); 330 IDT_ISLTL_ADDRESS_CAP, &regval);
355 331
356 pr_debug("RIO: %s Implementation Specific LTL errors" \ 332 pr_debug("RIO: %s Implementation Specific LTL errors" \
@@ -358,13 +334,12 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
358 rio_name(rdev), em_ltlerrdet, regval); 334 rio_name(rdev), em_ltlerrdet, regval);
359 335
360 /* Clear implementation specific address capture CSR */ 336 /* Clear implementation specific address capture CSR */
361 rio_mport_write_config_32(mport, destid, hopcount, 337 rio_write_config_32(rdev, IDT_ISLTL_ADDRESS_CAP, 0);
362 IDT_ISLTL_ADDRESS_CAP, 0);
363 338
364 } 339 }
365 } 340 }
366 341
367 rio_mport_read_config_32(mport, destid, hopcount, 342 rio_read_config_32(rdev,
368 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); 343 rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet);
369 if (em_perrdet) { 344 if (em_perrdet) {
370 /* Service Port-Level Error(s) */ 345 /* Service Port-Level Error(s) */
@@ -372,14 +347,14 @@ idtg2_em_handler(struct rio_dev *rdev, u8 portnum)
372 /* Implementation Specific port error reported */ 347 /* Implementation Specific port error reported */
373 348
374 /* Get IS errors reported */ 349 /* Get IS errors reported */
375 rio_mport_read_config_32(mport, destid, hopcount, 350 rio_read_config_32(rdev,
376 IDT_PORT_ISERR_DET(portnum), &regval); 351 IDT_PORT_ISERR_DET(portnum), &regval);
377 352
378 pr_debug("RIO: %s Implementation Specific Port" \ 353 pr_debug("RIO: %s Implementation Specific Port" \
379 " errors 0x%x\n", rio_name(rdev), regval); 354 " errors 0x%x\n", rio_name(rdev), regval);
380 355
381 /* Clear all implementation specific events */ 356 /* Clear all implementation specific events */
382 rio_mport_write_config_32(mport, destid, hopcount, 357 rio_write_config_32(rdev,
383 IDT_PORT_ISERR_DET(portnum), 0); 358 IDT_PORT_ISERR_DET(portnum), 0);
384 } 359 }
385 } 360 }
@@ -391,14 +366,10 @@ static ssize_t
391idtg2_show_errlog(struct device *dev, struct device_attribute *attr, char *buf) 366idtg2_show_errlog(struct device *dev, struct device_attribute *attr, char *buf)
392{ 367{
393 struct rio_dev *rdev = to_rio_dev(dev); 368 struct rio_dev *rdev = to_rio_dev(dev);
394 struct rio_mport *mport = rdev->net->hport;
395 u16 destid = rdev->rswitch->destid;
396 u8 hopcount = rdev->rswitch->hopcount;
397 ssize_t len = 0; 369 ssize_t len = 0;
398 u32 regval; 370 u32 regval;
399 371
400 while (!rio_mport_read_config_32(mport, destid, hopcount, 372 while (!rio_read_config_32(rdev, IDT_ERR_RD, &regval)) {
401 IDT_ERR_RD, &regval)) {
402 if (!regval) /* 0 = end of log */ 373 if (!regval) /* 0 = end of log */
403 break; 374 break;
404 len += snprintf(buf + len, PAGE_SIZE - len, 375 len += snprintf(buf + len, PAGE_SIZE - len,
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c
index fc9f6374f759..3a971077e7bf 100644
--- a/drivers/rapidio/switches/idtcps.c
+++ b/drivers/rapidio/switches/idtcps.c
@@ -117,10 +117,6 @@ idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
117 117
118static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) 118static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
119{ 119{
120 struct rio_mport *mport = rdev->net->hport;
121 u16 destid = rdev->rswitch->destid;
122 u8 hopcount = rdev->rswitch->hopcount;
123
124 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); 120 pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev));
125 rdev->rswitch->add_entry = idtcps_route_add_entry; 121 rdev->rswitch->add_entry = idtcps_route_add_entry;
126 rdev->rswitch->get_entry = idtcps_route_get_entry; 122 rdev->rswitch->get_entry = idtcps_route_get_entry;
@@ -132,7 +128,7 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum)
132 128
133 if (do_enum) { 129 if (do_enum) {
134 /* set TVAL = ~50us */ 130 /* set TVAL = ~50us */
135 rio_mport_write_config_32(mport, destid, hopcount, 131 rio_write_config_32(rdev,
136 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); 132 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8);
137 } 133 }
138 134
diff --git a/drivers/rapidio/switches/tsi568.c b/drivers/rapidio/switches/tsi568.c
index b9a389b9f812..3994c00aa01f 100644
--- a/drivers/rapidio/switches/tsi568.c
+++ b/drivers/rapidio/switches/tsi568.c
@@ -113,22 +113,17 @@ tsi568_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount,
113static int 113static int
114tsi568_em_init(struct rio_dev *rdev) 114tsi568_em_init(struct rio_dev *rdev)
115{ 115{
116 struct rio_mport *mport = rdev->net->hport;
117 u16 destid = rdev->rswitch->destid;
118 u8 hopcount = rdev->rswitch->hopcount;
119 u32 regval; 116 u32 regval;
120 int portnum; 117 int portnum;
121 118
122 pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount); 119 pr_debug("TSI568 %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
123 120
124 /* Make sure that Port-Writes are disabled (for all ports) */ 121 /* Make sure that Port-Writes are disabled (for all ports) */
125 for (portnum = 0; 122 for (portnum = 0;
126 portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { 123 portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) {
127 rio_mport_read_config_32(mport, destid, hopcount, 124 rio_read_config_32(rdev, TSI568_SP_MODE(portnum), &regval);
128 TSI568_SP_MODE(portnum), &regval); 125 rio_write_config_32(rdev, TSI568_SP_MODE(portnum),
129 rio_mport_write_config_32(mport, destid, hopcount, 126 regval | TSI568_SP_MODE_PW_DIS);
130 TSI568_SP_MODE(portnum),
131 regval | TSI568_SP_MODE_PW_DIS);
132 } 127 }
133 128
134 return 0; 129 return 0;
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c
index 2003fb63c404..1a62934bfebc 100644
--- a/drivers/rapidio/switches/tsi57x.c
+++ b/drivers/rapidio/switches/tsi57x.c
@@ -158,48 +158,45 @@ tsi57x_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount,
158static int 158static int
159tsi57x_em_init(struct rio_dev *rdev) 159tsi57x_em_init(struct rio_dev *rdev)
160{ 160{
161 struct rio_mport *mport = rdev->net->hport;
162 u16 destid = rdev->rswitch->destid;
163 u8 hopcount = rdev->rswitch->hopcount;
164 u32 regval; 161 u32 regval;
165 int portnum; 162 int portnum;
166 163
167 pr_debug("TSI578 %s [%d:%d]\n", __func__, destid, hopcount); 164 pr_debug("TSI578 %s [%d:%d]\n", __func__, rdev->destid, rdev->hopcount);
168 165
169 for (portnum = 0; 166 for (portnum = 0;
170 portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { 167 portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) {
171 /* Make sure that Port-Writes are enabled (for all ports) */ 168 /* Make sure that Port-Writes are enabled (for all ports) */
172 rio_mport_read_config_32(mport, destid, hopcount, 169 rio_read_config_32(rdev,
173 TSI578_SP_MODE(portnum), &regval); 170 TSI578_SP_MODE(portnum), &regval);
174 rio_mport_write_config_32(mport, destid, hopcount, 171 rio_write_config_32(rdev,
175 TSI578_SP_MODE(portnum), 172 TSI578_SP_MODE(portnum),
176 regval & ~TSI578_SP_MODE_PW_DIS); 173 regval & ~TSI578_SP_MODE_PW_DIS);
177 174
178 /* Clear all pending interrupts */ 175 /* Clear all pending interrupts */
179 rio_mport_read_config_32(mport, destid, hopcount, 176 rio_read_config_32(rdev,
180 rdev->phys_efptr + 177 rdev->phys_efptr +
181 RIO_PORT_N_ERR_STS_CSR(portnum), 178 RIO_PORT_N_ERR_STS_CSR(portnum),
182 &regval); 179 &regval);
183 rio_mport_write_config_32(mport, destid, hopcount, 180 rio_write_config_32(rdev,
184 rdev->phys_efptr + 181 rdev->phys_efptr +
185 RIO_PORT_N_ERR_STS_CSR(portnum), 182 RIO_PORT_N_ERR_STS_CSR(portnum),
186 regval & 0x07120214); 183 regval & 0x07120214);
187 184
188 rio_mport_read_config_32(mport, destid, hopcount, 185 rio_read_config_32(rdev,
189 TSI578_SP_INT_STATUS(portnum), &regval); 186 TSI578_SP_INT_STATUS(portnum), &regval);
190 rio_mport_write_config_32(mport, destid, hopcount, 187 rio_write_config_32(rdev,
191 TSI578_SP_INT_STATUS(portnum), 188 TSI578_SP_INT_STATUS(portnum),
192 regval & 0x000700bd); 189 regval & 0x000700bd);
193 190
194 /* Enable all interrupts to allow ports to send a port-write */ 191 /* Enable all interrupts to allow ports to send a port-write */
195 rio_mport_read_config_32(mport, destid, hopcount, 192 rio_read_config_32(rdev,
196 TSI578_SP_CTL_INDEP(portnum), &regval); 193 TSI578_SP_CTL_INDEP(portnum), &regval);
197 rio_mport_write_config_32(mport, destid, hopcount, 194 rio_write_config_32(rdev,
198 TSI578_SP_CTL_INDEP(portnum), 195 TSI578_SP_CTL_INDEP(portnum),
199 regval | 0x000b0000); 196 regval | 0x000b0000);
200 197
201 /* Skip next (odd) port if the current port is in x4 mode */ 198 /* Skip next (odd) port if the current port is in x4 mode */
202 rio_mport_read_config_32(mport, destid, hopcount, 199 rio_read_config_32(rdev,
203 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), 200 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
204 &regval); 201 &regval);
205 if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4) 202 if ((regval & RIO_PORT_N_CTL_PWIDTH) == RIO_PORT_N_CTL_PWIDTH_4)
@@ -207,7 +204,7 @@ tsi57x_em_init(struct rio_dev *rdev)
207 } 204 }
208 205
209 /* set TVAL = ~50us */ 206 /* set TVAL = ~50us */
210 rio_mport_write_config_32(mport, destid, hopcount, 207 rio_write_config_32(rdev,
211 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x9a << 8); 208 rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x9a << 8);
212 209
213 return 0; 210 return 0;
@@ -217,14 +214,12 @@ static int
217tsi57x_em_handler(struct rio_dev *rdev, u8 portnum) 214tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
218{ 215{
219 struct rio_mport *mport = rdev->net->hport; 216 struct rio_mport *mport = rdev->net->hport;
220 u16 destid = rdev->rswitch->destid;
221 u8 hopcount = rdev->rswitch->hopcount;
222 u32 intstat, err_status; 217 u32 intstat, err_status;
223 int sendcount, checkcount; 218 int sendcount, checkcount;
224 u8 route_port; 219 u8 route_port;
225 u32 regval; 220 u32 regval;
226 221
227 rio_mport_read_config_32(mport, destid, hopcount, 222 rio_read_config_32(rdev,
228 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), 223 rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum),
229 &err_status); 224 &err_status);
230 225
@@ -232,15 +227,15 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
232 (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES | 227 (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES |
233 RIO_PORT_N_ERR_STS_PW_INP_ES))) { 228 RIO_PORT_N_ERR_STS_PW_INP_ES))) {
234 /* Remove any queued packets by locking/unlocking port */ 229 /* Remove any queued packets by locking/unlocking port */
235 rio_mport_read_config_32(mport, destid, hopcount, 230 rio_read_config_32(rdev,
236 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), 231 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
237 &regval); 232 &regval);
238 if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) { 233 if (!(regval & RIO_PORT_N_CTL_LOCKOUT)) {
239 rio_mport_write_config_32(mport, destid, hopcount, 234 rio_write_config_32(rdev,
240 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), 235 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
241 regval | RIO_PORT_N_CTL_LOCKOUT); 236 regval | RIO_PORT_N_CTL_LOCKOUT);
242 udelay(50); 237 udelay(50);
243 rio_mport_write_config_32(mport, destid, hopcount, 238 rio_write_config_32(rdev,
244 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum), 239 rdev->phys_efptr + RIO_PORT_N_CTL_CSR(portnum),
245 regval); 240 regval);
246 } 241 }
@@ -248,7 +243,7 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
248 /* Read from link maintenance response register to clear 243 /* Read from link maintenance response register to clear
249 * valid bit 244 * valid bit
250 */ 245 */
251 rio_mport_read_config_32(mport, destid, hopcount, 246 rio_read_config_32(rdev,
252 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum), 247 rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(portnum),
253 &regval); 248 &regval);
254 249
@@ -257,13 +252,12 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
257 */ 252 */
258 sendcount = 3; 253 sendcount = 3;
259 while (sendcount) { 254 while (sendcount) {
260 rio_mport_write_config_32(mport, destid, hopcount, 255 rio_write_config_32(rdev,
261 TSI578_SP_CS_TX(portnum), 0x40fc8000); 256 TSI578_SP_CS_TX(portnum), 0x40fc8000);
262 checkcount = 3; 257 checkcount = 3;
263 while (checkcount--) { 258 while (checkcount--) {
264 udelay(50); 259 udelay(50);
265 rio_mport_read_config_32( 260 rio_read_config_32(rdev,
266 mport, destid, hopcount,
267 rdev->phys_efptr + 261 rdev->phys_efptr +
268 RIO_PORT_N_MNT_RSP_CSR(portnum), 262 RIO_PORT_N_MNT_RSP_CSR(portnum),
269 &regval); 263 &regval);
@@ -277,25 +271,23 @@ tsi57x_em_handler(struct rio_dev *rdev, u8 portnum)
277 271
278exit_es: 272exit_es:
279 /* Clear implementation specific error status bits */ 273 /* Clear implementation specific error status bits */
280 rio_mport_read_config_32(mport, destid, hopcount, 274 rio_read_config_32(rdev, TSI578_SP_INT_STATUS(portnum), &intstat);
281 TSI578_SP_INT_STATUS(portnum), &intstat);
282 pr_debug("TSI578[%x:%x] SP%d_INT_STATUS=0x%08x\n", 275 pr_debug("TSI578[%x:%x] SP%d_INT_STATUS=0x%08x\n",
283 destid, hopcount, portnum, intstat); 276 rdev->destid, rdev->hopcount, portnum, intstat);
284 277
285 if (intstat & 0x10000) { 278 if (intstat & 0x10000) {
286 rio_mport_read_config_32(mport, destid, hopcount, 279 rio_read_config_32(rdev,
287 TSI578_SP_LUT_PEINF(portnum), &regval); 280 TSI578_SP_LUT_PEINF(portnum), &regval);
288 regval = (mport->sys_size) ? (regval >> 16) : (regval >> 24); 281 regval = (mport->sys_size) ? (regval >> 16) : (regval >> 24);
289 route_port = rdev->rswitch->route_table[regval]; 282 route_port = rdev->rswitch->route_table[regval];
290 pr_debug("RIO: TSI578[%s] P%d LUT Parity Error (destID=%d)\n", 283 pr_debug("RIO: TSI578[%s] P%d LUT Parity Error (destID=%d)\n",
291 rio_name(rdev), portnum, regval); 284 rio_name(rdev), portnum, regval);
292 tsi57x_route_add_entry(mport, destid, hopcount, 285 tsi57x_route_add_entry(mport, rdev->destid, rdev->hopcount,
293 RIO_GLOBAL_TABLE, regval, route_port); 286 RIO_GLOBAL_TABLE, regval, route_port);
294 } 287 }
295 288
296 rio_mport_write_config_32(mport, destid, hopcount, 289 rio_write_config_32(rdev, TSI578_SP_INT_STATUS(portnum),
297 TSI578_SP_INT_STATUS(portnum), 290 intstat & 0x000700bd);
298 intstat & 0x000700bd);
299 291
300 return 0; 292 return 0;
301} 293}