diff options
Diffstat (limited to 'drivers/rapidio/rio.c')
-rw-r--r-- | drivers/rapidio/rio.c | 74 |
1 files changed, 22 insertions, 52 deletions
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 | */ |
472 | int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) | 472 | int 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 | ®val); | 478 | ®val); |
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 | |||
507 | rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) | 500 | rio_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 | */ |
568 | static int rio_chk_dev_access(struct rio_dev *rdev) | 559 | static 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) | |||
588 | static int | 572 | static int |
589 | rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) | 573 | rio_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 | ®val); | 583 | ®val); |
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 | ®val); | 601 | ®val); |
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 | */ |
636 | static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) | 617 | static 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 | ®val); | 644 | ®val); |
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 | } |
700 | rd_err: | 677 | rd_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: | |||
730 | int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | 707 | int 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 | ||