diff options
Diffstat (limited to 'drivers/rapidio')
-rw-r--r-- | drivers/rapidio/rio-driver.c | 2 | ||||
-rw-r--r-- | drivers/rapidio/rio-scan.c | 187 | ||||
-rw-r--r-- | drivers/rapidio/rio-sysfs.c | 26 | ||||
-rw-r--r-- | drivers/rapidio/rio.c | 330 | ||||
-rw-r--r-- | drivers/rapidio/rio.h | 5 | ||||
-rw-r--r-- | drivers/rapidio/switches/Kconfig | 7 | ||||
-rw-r--r-- | drivers/rapidio/switches/Makefile | 1 | ||||
-rw-r--r-- | drivers/rapidio/switches/idt_gen2.c | 447 | ||||
-rw-r--r-- | drivers/rapidio/switches/idtcps.c | 10 | ||||
-rw-r--r-- | drivers/rapidio/switches/tsi568.c | 15 | ||||
-rw-r--r-- | drivers/rapidio/switches/tsi57x.c | 7 |
11 files changed, 882 insertions, 155 deletions
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c index 3222fa3c808c..0f4a53bdaa3c 100644 --- a/drivers/rapidio/rio-driver.c +++ b/drivers/rapidio/rio-driver.c | |||
@@ -192,7 +192,7 @@ static int rio_match_bus(struct device *dev, struct device_driver *drv) | |||
192 | out:return 0; | 192 | out:return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | static struct device rio_bus = { | 195 | struct device rio_bus = { |
196 | .init_name = "rapidio", | 196 | .init_name = "rapidio", |
197 | }; | 197 | }; |
198 | 198 | ||
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 8070e074c739..1eb82c4c712e 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
@@ -48,7 +48,7 @@ DEFINE_SPINLOCK(rio_global_list_lock); | |||
48 | static int next_destid = 0; | 48 | static int next_destid = 0; |
49 | static int next_switchid = 0; | 49 | static int next_switchid = 0; |
50 | static int next_net = 0; | 50 | static int next_net = 0; |
51 | static int next_comptag; | 51 | static int next_comptag = 1; |
52 | 52 | ||
53 | static struct timer_list rio_enum_timer = | 53 | static struct timer_list rio_enum_timer = |
54 | TIMER_INITIALIZER(rio_enum_timeout, 0, 0); | 54 | TIMER_INITIALIZER(rio_enum_timeout, 0, 0); |
@@ -121,27 +121,6 @@ static int rio_clear_locks(struct rio_mport *port) | |||
121 | u32 result; | 121 | u32 result; |
122 | int ret = 0; | 122 | int ret = 0; |
123 | 123 | ||
124 | /* Assign component tag to all devices */ | ||
125 | next_comptag = 1; | ||
126 | rio_local_write_config_32(port, RIO_COMPONENT_TAG_CSR, next_comptag++); | ||
127 | |||
128 | list_for_each_entry(rdev, &rio_devices, global_list) { | ||
129 | /* Mark device as discovered */ | ||
130 | rio_read_config_32(rdev, | ||
131 | rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR, | ||
132 | &result); | ||
133 | rio_write_config_32(rdev, | ||
134 | rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR, | ||
135 | result | RIO_PORT_GEN_DISCOVERED); | ||
136 | |||
137 | rio_write_config_32(rdev, RIO_COMPONENT_TAG_CSR, next_comptag); | ||
138 | rdev->comp_tag = next_comptag++; | ||
139 | if (next_comptag >= 0x10000) { | ||
140 | pr_err("RIO: Component Tag Counter Overflow\n"); | ||
141 | break; | ||
142 | } | ||
143 | } | ||
144 | |||
145 | /* Release host device id locks */ | 124 | /* Release host device id locks */ |
146 | rio_local_write_config_32(port, RIO_HOST_DID_LOCK_CSR, | 125 | rio_local_write_config_32(port, RIO_HOST_DID_LOCK_CSR, |
147 | port->host_deviceid); | 126 | port->host_deviceid); |
@@ -162,6 +141,15 @@ static int rio_clear_locks(struct rio_mport *port) | |||
162 | rdev->vid, rdev->did); | 141 | rdev->vid, rdev->did); |
163 | ret = -EINVAL; | 142 | ret = -EINVAL; |
164 | } | 143 | } |
144 | |||
145 | /* Mark device as discovered and enable master */ | ||
146 | rio_read_config_32(rdev, | ||
147 | rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR, | ||
148 | &result); | ||
149 | result |= RIO_PORT_GEN_DISCOVERED | RIO_PORT_GEN_MASTER; | ||
150 | rio_write_config_32(rdev, | ||
151 | rdev->phys_efptr + RIO_PORT_GEN_CTL_CSR, | ||
152 | result); | ||
165 | } | 153 | } |
166 | 154 | ||
167 | return ret; | 155 | return ret; |
@@ -420,11 +408,27 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
420 | hopcount, RIO_EFB_ERR_MGMNT); | 408 | hopcount, RIO_EFB_ERR_MGMNT); |
421 | } | 409 | } |
422 | 410 | ||
411 | if (rdev->pef & (RIO_PEF_SWITCH | RIO_PEF_MULTIPORT)) { | ||
412 | rio_mport_read_config_32(port, destid, hopcount, | ||
413 | RIO_SWP_INFO_CAR, &rdev->swpinfo); | ||
414 | } | ||
415 | |||
423 | rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR, | 416 | rio_mport_read_config_32(port, destid, hopcount, RIO_SRC_OPS_CAR, |
424 | &rdev->src_ops); | 417 | &rdev->src_ops); |
425 | rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR, | 418 | rio_mport_read_config_32(port, destid, hopcount, RIO_DST_OPS_CAR, |
426 | &rdev->dst_ops); | 419 | &rdev->dst_ops); |
427 | 420 | ||
421 | if (do_enum) { | ||
422 | /* Assign component tag to device */ | ||
423 | if (next_comptag >= 0x10000) { | ||
424 | pr_err("RIO: Component Tag Counter Overflow\n"); | ||
425 | goto cleanup; | ||
426 | } | ||
427 | rio_mport_write_config_32(port, destid, hopcount, | ||
428 | RIO_COMPONENT_TAG_CSR, next_comptag); | ||
429 | rdev->comp_tag = next_comptag++; | ||
430 | } | ||
431 | |||
428 | if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) { | 432 | if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) { |
429 | if (do_enum) { | 433 | if (do_enum) { |
430 | rio_set_device_id(port, destid, hopcount, next_destid); | 434 | rio_set_device_id(port, destid, hopcount, next_destid); |
@@ -439,9 +443,10 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
439 | 443 | ||
440 | /* If a PE has both switch and other functions, show it as a switch */ | 444 | /* If a PE has both switch and other functions, show it as a switch */ |
441 | if (rio_is_switch(rdev)) { | 445 | if (rio_is_switch(rdev)) { |
442 | rio_mport_read_config_32(port, destid, hopcount, | 446 | rswitch = kzalloc(sizeof(*rswitch) + |
443 | RIO_SWP_INFO_CAR, &rdev->swpinfo); | 447 | RIO_GET_TOTAL_PORTS(rdev->swpinfo) * |
444 | rswitch = kzalloc(sizeof(struct rio_switch), GFP_KERNEL); | 448 | sizeof(rswitch->nextdev[0]), |
449 | GFP_KERNEL); | ||
445 | if (!rswitch) | 450 | if (!rswitch) |
446 | goto cleanup; | 451 | goto cleanup; |
447 | rswitch->switchid = next_switchid; | 452 | rswitch->switchid = next_switchid; |
@@ -458,6 +463,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
458 | rdid++) | 463 | rdid++) |
459 | rswitch->route_table[rdid] = RIO_INVALID_ROUTE; | 464 | rswitch->route_table[rdid] = RIO_INVALID_ROUTE; |
460 | rdev->rswitch = rswitch; | 465 | rdev->rswitch = rswitch; |
466 | rswitch->rdev = rdev; | ||
461 | dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id, | 467 | dev_set_name(&rdev->dev, "%02x:s:%04x", rdev->net->id, |
462 | rdev->rswitch->switchid); | 468 | rdev->rswitch->switchid); |
463 | rio_switch_init(rdev, do_enum); | 469 | rio_switch_init(rdev, do_enum); |
@@ -478,6 +484,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, | |||
478 | } | 484 | } |
479 | 485 | ||
480 | rdev->dev.bus = &rio_bus_type; | 486 | rdev->dev.bus = &rio_bus_type; |
487 | rdev->dev.parent = &rio_bus; | ||
481 | 488 | ||
482 | device_initialize(&rdev->dev); | 489 | device_initialize(&rdev->dev); |
483 | rdev->dev.release = rio_release_dev; | 490 | rdev->dev.release = rio_release_dev; |
@@ -718,86 +725,53 @@ static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount) | |||
718 | } | 725 | } |
719 | 726 | ||
720 | /** | 727 | /** |
721 | * rio_get_swpinfo_inport- Gets the ingress port number | ||
722 | * @mport: Master port to send transaction | ||
723 | * @destid: Destination ID associated with the switch | ||
724 | * @hopcount: Number of hops to the device | ||
725 | * | ||
726 | * Returns port number being used to access the switch device. | ||
727 | */ | ||
728 | static u8 | ||
729 | rio_get_swpinfo_inport(struct rio_mport *mport, u16 destid, u8 hopcount) | ||
730 | { | ||
731 | u32 result; | ||
732 | |||
733 | rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR, | ||
734 | &result); | ||
735 | |||
736 | return (u8) (result & 0xff); | ||
737 | } | ||
738 | |||
739 | /** | ||
740 | * rio_get_swpinfo_tports- Gets total number of ports on the switch | ||
741 | * @mport: Master port to send transaction | ||
742 | * @destid: Destination ID associated with the switch | ||
743 | * @hopcount: Number of hops to the device | ||
744 | * | ||
745 | * Returns total numbers of ports implemented by the switch device. | ||
746 | */ | ||
747 | static u8 rio_get_swpinfo_tports(struct rio_mport *mport, u16 destid, | ||
748 | u8 hopcount) | ||
749 | { | ||
750 | u32 result; | ||
751 | |||
752 | rio_mport_read_config_32(mport, destid, hopcount, RIO_SWP_INFO_CAR, | ||
753 | &result); | ||
754 | |||
755 | return RIO_GET_TOTAL_PORTS(result); | ||
756 | } | ||
757 | |||
758 | /** | ||
759 | * rio_net_add_mport- Add a master port to a RIO network | ||
760 | * @net: RIO network | ||
761 | * @port: Master port to add | ||
762 | * | ||
763 | * Adds a master port to the network list of associated master | ||
764 | * ports.. | ||
765 | */ | ||
766 | static void rio_net_add_mport(struct rio_net *net, struct rio_mport *port) | ||
767 | { | ||
768 | spin_lock(&rio_global_list_lock); | ||
769 | list_add_tail(&port->nnode, &net->mports); | ||
770 | spin_unlock(&rio_global_list_lock); | ||
771 | } | ||
772 | |||
773 | /** | ||
774 | * rio_enum_peer- Recursively enumerate a RIO network through a master port | 728 | * rio_enum_peer- Recursively enumerate a RIO network through a master port |
775 | * @net: RIO network being enumerated | 729 | * @net: RIO network being enumerated |
776 | * @port: Master port to send transactions | 730 | * @port: Master port to send transactions |
777 | * @hopcount: Number of hops into the network | 731 | * @hopcount: Number of hops into the network |
732 | * @prev: Previous RIO device connected to the enumerated one | ||
733 | * @prev_port: Port on previous RIO device | ||
778 | * | 734 | * |
779 | * Recursively enumerates a RIO network. Transactions are sent via the | 735 | * Recursively enumerates a RIO network. Transactions are sent via the |
780 | * master port passed in @port. | 736 | * master port passed in @port. |
781 | */ | 737 | */ |
782 | static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | 738 | static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, |
783 | u8 hopcount) | 739 | u8 hopcount, struct rio_dev *prev, int prev_port) |
784 | { | 740 | { |
785 | int port_num; | 741 | int port_num; |
786 | int num_ports; | ||
787 | int cur_destid; | 742 | int cur_destid; |
788 | int sw_destid; | 743 | int sw_destid; |
789 | int sw_inport; | 744 | int sw_inport; |
790 | struct rio_dev *rdev; | 745 | struct rio_dev *rdev; |
791 | u16 destid; | 746 | u16 destid; |
747 | u32 regval; | ||
792 | int tmp; | 748 | int tmp; |
793 | 749 | ||
750 | if (rio_mport_chk_dev_access(port, | ||
751 | RIO_ANY_DESTID(port->sys_size), hopcount)) { | ||
752 | pr_debug("RIO: device access check failed\n"); | ||
753 | return -1; | ||
754 | } | ||
755 | |||
794 | if (rio_get_host_deviceid_lock(port, hopcount) == port->host_deviceid) { | 756 | if (rio_get_host_deviceid_lock(port, hopcount) == port->host_deviceid) { |
795 | pr_debug("RIO: PE already discovered by this host\n"); | 757 | pr_debug("RIO: PE already discovered by this host\n"); |
796 | /* | 758 | /* |
797 | * Already discovered by this host. Add it as another | 759 | * Already discovered by this host. Add it as another |
798 | * master port for the current network. | 760 | * link to the existing device. |
799 | */ | 761 | */ |
800 | rio_net_add_mport(net, port); | 762 | rio_mport_read_config_32(port, RIO_ANY_DESTID(port->sys_size), |
763 | hopcount, RIO_COMPONENT_TAG_CSR, ®val); | ||
764 | |||
765 | if (regval) { | ||
766 | rdev = rio_get_comptag((regval & 0xffff), NULL); | ||
767 | |||
768 | if (rdev && prev && rio_is_switch(prev)) { | ||
769 | pr_debug("RIO: redundant path to %s\n", | ||
770 | rio_name(rdev)); | ||
771 | prev->rswitch->nextdev[prev_port] = rdev; | ||
772 | } | ||
773 | } | ||
774 | |||
801 | return 0; | 775 | return 0; |
802 | } | 776 | } |
803 | 777 | ||
@@ -828,13 +802,15 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
828 | if (rdev) { | 802 | if (rdev) { |
829 | /* Add device to the global and bus/net specific list. */ | 803 | /* Add device to the global and bus/net specific list. */ |
830 | list_add_tail(&rdev->net_list, &net->devices); | 804 | list_add_tail(&rdev->net_list, &net->devices); |
805 | rdev->prev = prev; | ||
806 | if (prev && rio_is_switch(prev)) | ||
807 | prev->rswitch->nextdev[prev_port] = rdev; | ||
831 | } else | 808 | } else |
832 | return -1; | 809 | return -1; |
833 | 810 | ||
834 | if (rio_is_switch(rdev)) { | 811 | if (rio_is_switch(rdev)) { |
835 | next_switchid++; | 812 | next_switchid++; |
836 | sw_inport = rio_get_swpinfo_inport(port, | 813 | sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); |
837 | RIO_ANY_DESTID(port->sys_size), hopcount); | ||
838 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, | 814 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, |
839 | port->host_deviceid, sw_inport, 0); | 815 | port->host_deviceid, sw_inport, 0); |
840 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; | 816 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; |
@@ -847,14 +823,14 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
847 | rdev->rswitch->route_table[destid] = sw_inport; | 823 | rdev->rswitch->route_table[destid] = sw_inport; |
848 | } | 824 | } |
849 | 825 | ||
850 | num_ports = | ||
851 | rio_get_swpinfo_tports(port, RIO_ANY_DESTID(port->sys_size), | ||
852 | hopcount); | ||
853 | pr_debug( | 826 | pr_debug( |
854 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", | 827 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", |
855 | rio_name(rdev), rdev->vid, rdev->did, num_ports); | 828 | rio_name(rdev), rdev->vid, rdev->did, |
829 | RIO_GET_TOTAL_PORTS(rdev->swpinfo)); | ||
856 | sw_destid = next_destid; | 830 | sw_destid = next_destid; |
857 | for (port_num = 0; port_num < num_ports; port_num++) { | 831 | for (port_num = 0; |
832 | port_num < RIO_GET_TOTAL_PORTS(rdev->swpinfo); | ||
833 | port_num++) { | ||
858 | /*Enable Input Output Port (transmitter reviever)*/ | 834 | /*Enable Input Output Port (transmitter reviever)*/ |
859 | rio_enable_rx_tx_port(port, 0, | 835 | rio_enable_rx_tx_port(port, 0, |
860 | RIO_ANY_DESTID(port->sys_size), | 836 | RIO_ANY_DESTID(port->sys_size), |
@@ -879,7 +855,8 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
879 | RIO_ANY_DESTID(port->sys_size), | 855 | RIO_ANY_DESTID(port->sys_size), |
880 | port_num, 0); | 856 | port_num, 0); |
881 | 857 | ||
882 | if (rio_enum_peer(net, port, hopcount + 1) < 0) | 858 | if (rio_enum_peer(net, port, hopcount + 1, |
859 | rdev, port_num) < 0) | ||
883 | return -1; | 860 | return -1; |
884 | 861 | ||
885 | /* Update routing tables */ | 862 | /* Update routing tables */ |
@@ -945,10 +922,11 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
945 | */ | 922 | */ |
946 | static int rio_enum_complete(struct rio_mport *port) | 923 | static int rio_enum_complete(struct rio_mport *port) |
947 | { | 924 | { |
948 | u32 tag_csr; | 925 | u32 regval; |
949 | 926 | ||
950 | rio_local_read_config_32(port, RIO_COMPONENT_TAG_CSR, &tag_csr); | 927 | rio_local_read_config_32(port, port->phys_efptr + RIO_PORT_GEN_CTL_CSR, |
951 | return (tag_csr & 0xffff) ? 1 : 0; | 928 | ®val); |
929 | return (regval & RIO_PORT_GEN_MASTER) ? 1 : 0; | ||
952 | } | 930 | } |
953 | 931 | ||
954 | /** | 932 | /** |
@@ -966,7 +944,6 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, | |||
966 | u8 hopcount) | 944 | u8 hopcount) |
967 | { | 945 | { |
968 | u8 port_num, route_port; | 946 | u8 port_num, route_port; |
969 | int num_ports; | ||
970 | struct rio_dev *rdev; | 947 | struct rio_dev *rdev; |
971 | u16 ndestid; | 948 | u16 ndestid; |
972 | 949 | ||
@@ -983,13 +960,14 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, | |||
983 | /* Associated destid is how we accessed this switch */ | 960 | /* Associated destid is how we accessed this switch */ |
984 | rdev->rswitch->destid = destid; | 961 | rdev->rswitch->destid = destid; |
985 | 962 | ||
986 | num_ports = rio_get_swpinfo_tports(port, destid, hopcount); | ||
987 | pr_debug( | 963 | pr_debug( |
988 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", | 964 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", |
989 | rio_name(rdev), rdev->vid, rdev->did, num_ports); | 965 | rio_name(rdev), rdev->vid, rdev->did, |
990 | for (port_num = 0; port_num < num_ports; port_num++) { | 966 | RIO_GET_TOTAL_PORTS(rdev->swpinfo)); |
991 | if (rio_get_swpinfo_inport(port, destid, hopcount) == | 967 | for (port_num = 0; |
992 | port_num) | 968 | port_num < RIO_GET_TOTAL_PORTS(rdev->swpinfo); |
969 | port_num++) { | ||
970 | if (RIO_GET_PORT_NUM(rdev->swpinfo) == port_num) | ||
993 | continue; | 971 | continue; |
994 | 972 | ||
995 | if (rio_sport_is_active | 973 | if (rio_sport_is_active |
@@ -1011,6 +989,8 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, | |||
1011 | break; | 989 | break; |
1012 | } | 990 | } |
1013 | 991 | ||
992 | if (ndestid == RIO_ANY_DESTID(port->sys_size)) | ||
993 | continue; | ||
1014 | rio_unlock_device(port, destid, hopcount); | 994 | rio_unlock_device(port, destid, hopcount); |
1015 | if (rio_disc_peer | 995 | if (rio_disc_peer |
1016 | (net, port, ndestid, hopcount + 1) < 0) | 996 | (net, port, ndestid, hopcount + 1) < 0) |
@@ -1108,8 +1088,7 @@ static void rio_update_route_tables(struct rio_mport *port) | |||
1108 | if (rswitch->destid == destid) | 1088 | if (rswitch->destid == destid) |
1109 | continue; | 1089 | continue; |
1110 | 1090 | ||
1111 | sport = rio_get_swpinfo_inport(port, | 1091 | sport = RIO_GET_PORT_NUM(rswitch->rdev->swpinfo); |
1112 | rswitch->destid, rswitch->hopcount); | ||
1113 | 1092 | ||
1114 | if (rswitch->add_entry) { | 1093 | if (rswitch->add_entry) { |
1115 | rio_route_add_entry(port, rswitch, | 1094 | rio_route_add_entry(port, rswitch, |
@@ -1184,7 +1163,11 @@ int __devinit rio_enum_mport(struct rio_mport *mport) | |||
1184 | /* Enable Input Output Port (transmitter reviever) */ | 1163 | /* Enable Input Output Port (transmitter reviever) */ |
1185 | rio_enable_rx_tx_port(mport, 1, 0, 0, 0); | 1164 | rio_enable_rx_tx_port(mport, 1, 0, 0, 0); |
1186 | 1165 | ||
1187 | if (rio_enum_peer(net, mport, 0) < 0) { | 1166 | /* Set component tag for host */ |
1167 | rio_local_write_config_32(mport, RIO_COMPONENT_TAG_CSR, | ||
1168 | next_comptag++); | ||
1169 | |||
1170 | if (rio_enum_peer(net, mport, 0, NULL, 0) < 0) { | ||
1188 | /* A higher priority host won enumeration, bail. */ | 1171 | /* A higher priority host won enumeration, bail. */ |
1189 | printk(KERN_INFO | 1172 | printk(KERN_INFO |
1190 | "RIO: master port %d device has lost enumeration to a remote host\n", | 1173 | "RIO: master port %d device has lost enumeration to a remote host\n", |
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c index 00b475658356..137ed93ee33f 100644 --- a/drivers/rapidio/rio-sysfs.c +++ b/drivers/rapidio/rio-sysfs.c | |||
@@ -40,9 +40,6 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch | |||
40 | char *str = buf; | 40 | char *str = buf; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | if (!rdev->rswitch) | ||
44 | goto out; | ||
45 | |||
46 | for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); | 43 | for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); |
47 | i++) { | 44 | i++) { |
48 | if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE) | 45 | if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE) |
@@ -52,7 +49,6 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch | |||
52 | rdev->rswitch->route_table[i]); | 49 | rdev->rswitch->route_table[i]); |
53 | } | 50 | } |
54 | 51 | ||
55 | out: | ||
56 | return (str - buf); | 52 | return (str - buf); |
57 | } | 53 | } |
58 | 54 | ||
@@ -63,10 +59,11 @@ struct device_attribute rio_dev_attrs[] = { | |||
63 | __ATTR_RO(asm_did), | 59 | __ATTR_RO(asm_did), |
64 | __ATTR_RO(asm_vid), | 60 | __ATTR_RO(asm_vid), |
65 | __ATTR_RO(asm_rev), | 61 | __ATTR_RO(asm_rev), |
66 | __ATTR_RO(routes), | ||
67 | __ATTR_NULL, | 62 | __ATTR_NULL, |
68 | }; | 63 | }; |
69 | 64 | ||
65 | static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL); | ||
66 | |||
70 | static ssize_t | 67 | static ssize_t |
71 | rio_read_config(struct file *filp, struct kobject *kobj, | 68 | rio_read_config(struct file *filp, struct kobject *kobj, |
72 | struct bin_attribute *bin_attr, | 69 | struct bin_attribute *bin_attr, |
@@ -218,7 +215,17 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev) | |||
218 | { | 215 | { |
219 | int err = 0; | 216 | int err = 0; |
220 | 217 | ||
221 | err = sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr); | 218 | err = device_create_bin_file(&rdev->dev, &rio_config_attr); |
219 | |||
220 | if (!err && rdev->rswitch) { | ||
221 | err = device_create_file(&rdev->dev, &dev_attr_routes); | ||
222 | if (!err && rdev->rswitch->sw_sysfs) | ||
223 | err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE); | ||
224 | } | ||
225 | |||
226 | if (err) | ||
227 | pr_warning("RIO: Failed to create attribute file(s) for %s\n", | ||
228 | rio_name(rdev)); | ||
222 | 229 | ||
223 | return err; | 230 | return err; |
224 | } | 231 | } |
@@ -231,5 +238,10 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev) | |||
231 | */ | 238 | */ |
232 | void rio_remove_sysfs_dev_files(struct rio_dev *rdev) | 239 | void rio_remove_sysfs_dev_files(struct rio_dev *rdev) |
233 | { | 240 | { |
234 | sysfs_remove_bin_file(&rdev->dev.kobj, &rio_config_attr); | 241 | device_remove_bin_file(&rdev->dev, &rio_config_attr); |
242 | if (rdev->rswitch) { | ||
243 | device_remove_file(&rdev->dev, &dev_attr_routes); | ||
244 | if (rdev->rswitch->sw_sysfs) | ||
245 | rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); | ||
246 | } | ||
235 | } | 247 | } |
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index 74e9d22d95fb..68cf0c99138a 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c | |||
@@ -443,7 +443,7 @@ rio_mport_get_physefb(struct rio_mport *port, int local, | |||
443 | * @from is not %NULL, searches continue from next device on the global | 443 | * @from is not %NULL, searches continue from next device on the global |
444 | * list. | 444 | * list. |
445 | */ | 445 | */ |
446 | static struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from) | 446 | struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from) |
447 | { | 447 | { |
448 | struct list_head *n; | 448 | struct list_head *n; |
449 | struct rio_dev *rdev; | 449 | struct rio_dev *rdev; |
@@ -495,6 +495,232 @@ int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock) | |||
495 | } | 495 | } |
496 | 496 | ||
497 | /** | 497 | /** |
498 | * rio_chk_dev_route - Validate route to the specified device. | ||
499 | * @rdev: RIO device failed to respond | ||
500 | * @nrdev: Last active device on the route to rdev | ||
501 | * @npnum: nrdev's port number on the route to rdev | ||
502 | * | ||
503 | * Follows a route to the specified RIO device to determine the last available | ||
504 | * device (and corresponding RIO port) on the route. | ||
505 | */ | ||
506 | static int | ||
507 | rio_chk_dev_route(struct rio_dev *rdev, struct rio_dev **nrdev, int *npnum) | ||
508 | { | ||
509 | u32 result; | ||
510 | int p_port, dstid, rc = -EIO; | ||
511 | struct rio_dev *prev = NULL; | ||
512 | |||
513 | /* Find switch with failed RIO link */ | ||
514 | while (rdev->prev && (rdev->prev->pef & RIO_PEF_SWITCH)) { | ||
515 | if (!rio_read_config_32(rdev->prev, RIO_DEV_ID_CAR, &result)) { | ||
516 | prev = rdev->prev; | ||
517 | break; | ||
518 | } | ||
519 | rdev = rdev->prev; | ||
520 | } | ||
521 | |||
522 | if (prev == NULL) | ||
523 | goto err_out; | ||
524 | |||
525 | dstid = (rdev->pef & RIO_PEF_SWITCH) ? | ||
526 | rdev->rswitch->destid : rdev->destid; | ||
527 | p_port = prev->rswitch->route_table[dstid]; | ||
528 | |||
529 | if (p_port != RIO_INVALID_ROUTE) { | ||
530 | pr_debug("RIO: link failed on [%s]-P%d\n", | ||
531 | rio_name(prev), p_port); | ||
532 | *nrdev = prev; | ||
533 | *npnum = p_port; | ||
534 | rc = 0; | ||
535 | } else | ||
536 | pr_debug("RIO: failed to trace route to %s\n", rio_name(rdev)); | ||
537 | err_out: | ||
538 | return rc; | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * rio_mport_chk_dev_access - Validate access to the specified device. | ||
543 | * @mport: Master port to send transactions | ||
544 | * @destid: Device destination ID in network | ||
545 | * @hopcount: Number of hops into the network | ||
546 | */ | ||
547 | int | ||
548 | rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, u8 hopcount) | ||
549 | { | ||
550 | int i = 0; | ||
551 | u32 tmp; | ||
552 | |||
553 | while (rio_mport_read_config_32(mport, destid, hopcount, | ||
554 | RIO_DEV_ID_CAR, &tmp)) { | ||
555 | i++; | ||
556 | if (i == RIO_MAX_CHK_RETRY) | ||
557 | return -EIO; | ||
558 | mdelay(1); | ||
559 | } | ||
560 | |||
561 | return 0; | ||
562 | } | ||
563 | |||
564 | /** | ||
565 | * rio_chk_dev_access - Validate access to the specified device. | ||
566 | * @rdev: Pointer to RIO device control structure | ||
567 | */ | ||
568 | static int rio_chk_dev_access(struct rio_dev *rdev) | ||
569 | { | ||
570 | u8 hopcount = 0xff; | ||
571 | u16 destid = rdev->destid; | ||
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 | } | ||
580 | |||
581 | /** | ||
582 | * rio_get_input_status - Sends a Link-Request/Input-Status control symbol and | ||
583 | * returns link-response (if requested). | ||
584 | * @rdev: RIO devive to issue Input-status command | ||
585 | * @pnum: Device port number to issue the command | ||
586 | * @lnkresp: Response from a link partner | ||
587 | */ | ||
588 | static int | ||
589 | rio_get_input_status(struct rio_dev *rdev, int pnum, u32 *lnkresp) | ||
590 | { | ||
591 | struct rio_mport *mport = rdev->net->hport; | ||
592 | u16 destid = rdev->rswitch->destid; | ||
593 | u8 hopcount = rdev->rswitch->hopcount; | ||
594 | u32 regval; | ||
595 | int checkcount; | ||
596 | |||
597 | if (lnkresp) { | ||
598 | /* Read from link maintenance response register | ||
599 | * to clear valid bit */ | ||
600 | rio_mport_read_config_32(mport, destid, hopcount, | ||
601 | rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), | ||
602 | ®val); | ||
603 | udelay(50); | ||
604 | } | ||
605 | |||
606 | /* Issue Input-status command */ | ||
607 | rio_mport_write_config_32(mport, destid, hopcount, | ||
608 | rdev->phys_efptr + RIO_PORT_N_MNT_REQ_CSR(pnum), | ||
609 | RIO_MNT_REQ_CMD_IS); | ||
610 | |||
611 | /* Exit if the response is not expected */ | ||
612 | if (lnkresp == NULL) | ||
613 | return 0; | ||
614 | |||
615 | checkcount = 3; | ||
616 | while (checkcount--) { | ||
617 | udelay(50); | ||
618 | rio_mport_read_config_32(mport, destid, hopcount, | ||
619 | rdev->phys_efptr + RIO_PORT_N_MNT_RSP_CSR(pnum), | ||
620 | ®val); | ||
621 | if (regval & RIO_PORT_N_MNT_RSP_RVAL) { | ||
622 | *lnkresp = regval; | ||
623 | return 0; | ||
624 | } | ||
625 | } | ||
626 | |||
627 | return -EIO; | ||
628 | } | ||
629 | |||
630 | /** | ||
631 | * rio_clr_err_stopped - Clears port Error-stopped states. | ||
632 | * @rdev: Pointer to RIO device control structure | ||
633 | * @pnum: Switch port number to clear errors | ||
634 | * @err_status: port error status (if 0 reads register from device) | ||
635 | */ | ||
636 | static int rio_clr_err_stopped(struct rio_dev *rdev, u32 pnum, u32 err_status) | ||
637 | { | ||
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]; | ||
642 | u32 regval; | ||
643 | u32 far_ackid, far_linkstat, near_ackid; | ||
644 | |||
645 | if (err_status == 0) | ||
646 | rio_mport_read_config_32(mport, destid, hopcount, | ||
647 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), | ||
648 | &err_status); | ||
649 | |||
650 | if (err_status & RIO_PORT_N_ERR_STS_PW_OUT_ES) { | ||
651 | pr_debug("RIO_EM: servicing Output Error-Stopped state\n"); | ||
652 | /* | ||
653 | * Send a Link-Request/Input-Status control symbol | ||
654 | */ | ||
655 | if (rio_get_input_status(rdev, pnum, ®val)) { | ||
656 | pr_debug("RIO_EM: Input-status response timeout\n"); | ||
657 | goto rd_err; | ||
658 | } | ||
659 | |||
660 | pr_debug("RIO_EM: SP%d Input-status response=0x%08x\n", | ||
661 | pnum, regval); | ||
662 | far_ackid = (regval & RIO_PORT_N_MNT_RSP_ASTAT) >> 5; | ||
663 | far_linkstat = regval & RIO_PORT_N_MNT_RSP_LSTAT; | ||
664 | rio_mport_read_config_32(mport, destid, hopcount, | ||
665 | rdev->phys_efptr + RIO_PORT_N_ACK_STS_CSR(pnum), | ||
666 | ®val); | ||
667 | pr_debug("RIO_EM: SP%d_ACK_STS_CSR=0x%08x\n", pnum, regval); | ||
668 | near_ackid = (regval & RIO_PORT_N_ACK_INBOUND) >> 24; | ||
669 | pr_debug("RIO_EM: SP%d far_ackID=0x%02x far_linkstat=0x%02x" \ | ||
670 | " near_ackID=0x%02x\n", | ||
671 | pnum, far_ackid, far_linkstat, near_ackid); | ||
672 | |||
673 | /* | ||
674 | * If required, synchronize ackIDs of near and | ||
675 | * far sides. | ||
676 | */ | ||
677 | if ((far_ackid != ((regval & RIO_PORT_N_ACK_OUTSTAND) >> 8)) || | ||
678 | (far_ackid != (regval & RIO_PORT_N_ACK_OUTBOUND))) { | ||
679 | /* Align near outstanding/outbound ackIDs with | ||
680 | * far inbound. | ||
681 | */ | ||
682 | rio_mport_write_config_32(mport, destid, | ||
683 | hopcount, rdev->phys_efptr + | ||
684 | RIO_PORT_N_ACK_STS_CSR(pnum), | ||
685 | (near_ackid << 24) | | ||
686 | (far_ackid << 8) | far_ackid); | ||
687 | /* Align far outstanding/outbound ackIDs with | ||
688 | * near inbound. | ||
689 | */ | ||
690 | far_ackid++; | ||
691 | if (nextdev) | ||
692 | rio_write_config_32(nextdev, | ||
693 | nextdev->phys_efptr + | ||
694 | RIO_PORT_N_ACK_STS_CSR(RIO_GET_PORT_NUM(nextdev->swpinfo)), | ||
695 | (far_ackid << 24) | | ||
696 | (near_ackid << 8) | near_ackid); | ||
697 | else | ||
698 | pr_debug("RIO_EM: Invalid nextdev pointer (NULL)\n"); | ||
699 | } | ||
700 | rd_err: | ||
701 | rio_mport_read_config_32(mport, destid, hopcount, | ||
702 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), | ||
703 | &err_status); | ||
704 | pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); | ||
705 | } | ||
706 | |||
707 | if ((err_status & RIO_PORT_N_ERR_STS_PW_INP_ES) && nextdev) { | ||
708 | pr_debug("RIO_EM: servicing Input Error-Stopped state\n"); | ||
709 | rio_get_input_status(nextdev, | ||
710 | RIO_GET_PORT_NUM(nextdev->swpinfo), NULL); | ||
711 | udelay(50); | ||
712 | |||
713 | rio_mport_read_config_32(mport, destid, hopcount, | ||
714 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(pnum), | ||
715 | &err_status); | ||
716 | pr_debug("RIO_EM: SP%d_ERR_STS_CSR=0x%08x\n", pnum, err_status); | ||
717 | } | ||
718 | |||
719 | return (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES | | ||
720 | RIO_PORT_N_ERR_STS_PW_INP_ES)) ? 1 : 0; | ||
721 | } | ||
722 | |||
723 | /** | ||
498 | * rio_inb_pwrite_handler - process inbound port-write message | 724 | * rio_inb_pwrite_handler - process inbound port-write message |
499 | * @pw_msg: pointer to inbound port-write message | 725 | * @pw_msg: pointer to inbound port-write message |
500 | * | 726 | * |
@@ -507,13 +733,13 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
507 | struct rio_mport *mport; | 733 | struct rio_mport *mport; |
508 | u8 hopcount; | 734 | u8 hopcount; |
509 | u16 destid; | 735 | u16 destid; |
510 | u32 err_status; | 736 | u32 err_status, em_perrdet, em_ltlerrdet; |
511 | int rc, portnum; | 737 | int rc, portnum; |
512 | 738 | ||
513 | rdev = rio_get_comptag(pw_msg->em.comptag, NULL); | 739 | rdev = rio_get_comptag(pw_msg->em.comptag, NULL); |
514 | if (rdev == NULL) { | 740 | if (rdev == NULL) { |
515 | /* Someting bad here (probably enumeration error) */ | 741 | /* Device removed or enumeration error */ |
516 | pr_err("RIO: %s No matching device for CTag 0x%08x\n", | 742 | pr_debug("RIO: %s No matching device for CTag 0x%08x\n", |
517 | __func__, pw_msg->em.comptag); | 743 | __func__, pw_msg->em.comptag); |
518 | return -EIO; | 744 | return -EIO; |
519 | } | 745 | } |
@@ -524,12 +750,11 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
524 | { | 750 | { |
525 | u32 i; | 751 | u32 i; |
526 | for (i = 0; i < RIO_PW_MSG_SIZE/sizeof(u32);) { | 752 | for (i = 0; i < RIO_PW_MSG_SIZE/sizeof(u32);) { |
527 | pr_debug("0x%02x: %08x %08x %08x %08x", | 753 | pr_debug("0x%02x: %08x %08x %08x %08x\n", |
528 | i*4, pw_msg->raw[i], pw_msg->raw[i + 1], | 754 | i*4, pw_msg->raw[i], pw_msg->raw[i + 1], |
529 | pw_msg->raw[i + 2], pw_msg->raw[i + 3]); | 755 | pw_msg->raw[i + 2], pw_msg->raw[i + 3]); |
530 | i += 4; | 756 | i += 4; |
531 | } | 757 | } |
532 | pr_debug("\n"); | ||
533 | } | 758 | } |
534 | #endif | 759 | #endif |
535 | 760 | ||
@@ -545,6 +770,26 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
545 | return 0; | 770 | return 0; |
546 | } | 771 | } |
547 | 772 | ||
773 | portnum = pw_msg->em.is_port & 0xFF; | ||
774 | |||
775 | /* Check if device and route to it are functional: | ||
776 | * Sometimes devices may send PW message(s) just before being | ||
777 | * powered down (or link being lost). | ||
778 | */ | ||
779 | if (rio_chk_dev_access(rdev)) { | ||
780 | pr_debug("RIO: device access failed - get link partner\n"); | ||
781 | /* Scan route to the device and identify failed link. | ||
782 | * This will replace device and port reported in PW message. | ||
783 | * PW message should not be used after this point. | ||
784 | */ | ||
785 | if (rio_chk_dev_route(rdev, &rdev, &portnum)) { | ||
786 | pr_err("RIO: Route trace for %s failed\n", | ||
787 | rio_name(rdev)); | ||
788 | return -EIO; | ||
789 | } | ||
790 | pw_msg = NULL; | ||
791 | } | ||
792 | |||
548 | /* For End-point devices processing stops here */ | 793 | /* For End-point devices processing stops here */ |
549 | if (!(rdev->pef & RIO_PEF_SWITCH)) | 794 | if (!(rdev->pef & RIO_PEF_SWITCH)) |
550 | return 0; | 795 | return 0; |
@@ -562,9 +807,6 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
562 | /* | 807 | /* |
563 | * Process the port-write notification from switch | 808 | * Process the port-write notification from switch |
564 | */ | 809 | */ |
565 | |||
566 | portnum = pw_msg->em.is_port & 0xFF; | ||
567 | |||
568 | if (rdev->rswitch->em_handle) | 810 | if (rdev->rswitch->em_handle) |
569 | rdev->rswitch->em_handle(rdev, portnum); | 811 | rdev->rswitch->em_handle(rdev, portnum); |
570 | 812 | ||
@@ -573,29 +815,28 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
573 | &err_status); | 815 | &err_status); |
574 | pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status); | 816 | pr_debug("RIO_PW: SP%d_ERR_STS_CSR=0x%08x\n", portnum, err_status); |
575 | 817 | ||
576 | if (pw_msg->em.errdetect) { | 818 | if (err_status & RIO_PORT_N_ERR_STS_PORT_OK) { |
577 | pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n", | ||
578 | portnum, pw_msg->em.errdetect); | ||
579 | /* Clear EM Port N Error Detect CSR */ | ||
580 | rio_mport_write_config_32(mport, destid, hopcount, | ||
581 | rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0); | ||
582 | } | ||
583 | 819 | ||
584 | if (pw_msg->em.ltlerrdet) { | 820 | if (!(rdev->rswitch->port_ok & (1 << portnum))) { |
585 | pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n", | 821 | rdev->rswitch->port_ok |= (1 << portnum); |
586 | pw_msg->em.ltlerrdet); | 822 | rio_set_port_lockout(rdev, portnum, 0); |
587 | /* Clear EM L/T Layer Error Detect CSR */ | 823 | /* Schedule Insertion Service */ |
588 | rio_mport_write_config_32(mport, destid, hopcount, | 824 | pr_debug("RIO_PW: Device Insertion on [%s]-P%d\n", |
589 | rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0); | 825 | rio_name(rdev), portnum); |
590 | } | 826 | } |
591 | 827 | ||
592 | /* Clear Port Errors */ | 828 | /* Clear error-stopped states (if reported). |
593 | rio_mport_write_config_32(mport, destid, hopcount, | 829 | * Depending on the link partner state, two attempts |
594 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), | 830 | * may be needed for successful recovery. |
595 | err_status & RIO_PORT_N_ERR_STS_CLR_MASK); | 831 | */ |
832 | if (err_status & (RIO_PORT_N_ERR_STS_PW_OUT_ES | | ||
833 | RIO_PORT_N_ERR_STS_PW_INP_ES)) { | ||
834 | if (rio_clr_err_stopped(rdev, portnum, err_status)) | ||
835 | rio_clr_err_stopped(rdev, portnum, 0); | ||
836 | } | ||
837 | } else { /* if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT) */ | ||
596 | 838 | ||
597 | if (rdev->rswitch->port_ok & (1 << portnum)) { | 839 | if (rdev->rswitch->port_ok & (1 << portnum)) { |
598 | if (err_status & RIO_PORT_N_ERR_STS_PORT_UNINIT) { | ||
599 | rdev->rswitch->port_ok &= ~(1 << portnum); | 840 | rdev->rswitch->port_ok &= ~(1 << portnum); |
600 | rio_set_port_lockout(rdev, portnum, 1); | 841 | rio_set_port_lockout(rdev, portnum, 1); |
601 | 842 | ||
@@ -608,21 +849,32 @@ int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg) | |||
608 | pr_debug("RIO_PW: Device Extraction on [%s]-P%d\n", | 849 | pr_debug("RIO_PW: Device Extraction on [%s]-P%d\n", |
609 | rio_name(rdev), portnum); | 850 | rio_name(rdev), portnum); |
610 | } | 851 | } |
611 | } else { | 852 | } |
612 | if (err_status & RIO_PORT_N_ERR_STS_PORT_OK) { | ||
613 | rdev->rswitch->port_ok |= (1 << portnum); | ||
614 | rio_set_port_lockout(rdev, portnum, 0); | ||
615 | 853 | ||
616 | /* Schedule Insertion Service */ | 854 | rio_mport_read_config_32(mport, destid, hopcount, |
617 | pr_debug("RIO_PW: Device Insertion on [%s]-P%d\n", | 855 | rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); |
618 | rio_name(rdev), portnum); | 856 | if (em_perrdet) { |
619 | } | 857 | pr_debug("RIO_PW: RIO_EM_P%d_ERR_DETECT=0x%08x\n", |
858 | portnum, em_perrdet); | ||
859 | /* Clear EM Port N Error Detect CSR */ | ||
860 | rio_mport_write_config_32(mport, destid, hopcount, | ||
861 | rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), 0); | ||
862 | } | ||
863 | |||
864 | rio_mport_read_config_32(mport, destid, hopcount, | ||
865 | rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); | ||
866 | if (em_ltlerrdet) { | ||
867 | pr_debug("RIO_PW: RIO_EM_LTL_ERR_DETECT=0x%08x\n", | ||
868 | em_ltlerrdet); | ||
869 | /* Clear EM L/T Layer Error Detect CSR */ | ||
870 | rio_mport_write_config_32(mport, destid, hopcount, | ||
871 | rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, 0); | ||
620 | } | 872 | } |
621 | 873 | ||
622 | /* Clear Port-Write Pending bit */ | 874 | /* Clear remaining error bits and Port-Write Pending bit */ |
623 | rio_mport_write_config_32(mport, destid, hopcount, | 875 | rio_mport_write_config_32(mport, destid, hopcount, |
624 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), | 876 | rdev->phys_efptr + RIO_PORT_N_ERR_STS_CSR(portnum), |
625 | RIO_PORT_N_ERR_STS_PW_PEND); | 877 | err_status); |
626 | 878 | ||
627 | return 0; | 879 | return 0; |
628 | } | 880 | } |
diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h index f27b7a9c47d2..b1af414f15e6 100644 --- a/drivers/rapidio/rio.h +++ b/drivers/rapidio/rio.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/rio.h> | 15 | #include <linux/rio.h> |
16 | 16 | ||
17 | #define RIO_MAX_CHK_RETRY 3 | ||
18 | |||
17 | /* Functions internal to the RIO core code */ | 19 | /* Functions internal to the RIO core code */ |
18 | 20 | ||
19 | extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid, | 21 | extern u32 rio_mport_get_feature(struct rio_mport *mport, int local, u16 destid, |
@@ -22,6 +24,8 @@ extern u32 rio_mport_get_physefb(struct rio_mport *port, int local, | |||
22 | u16 destid, u8 hopcount); | 24 | u16 destid, u8 hopcount); |
23 | extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid, | 25 | extern u32 rio_mport_get_efb(struct rio_mport *port, int local, u16 destid, |
24 | u8 hopcount, u32 from); | 26 | u8 hopcount, u32 from); |
27 | extern int rio_mport_chk_dev_access(struct rio_mport *mport, u16 destid, | ||
28 | u8 hopcount); | ||
25 | extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); | 29 | extern int rio_create_sysfs_dev_files(struct rio_dev *rdev); |
26 | extern int rio_enum_mport(struct rio_mport *mport); | 30 | extern int rio_enum_mport(struct rio_mport *mport); |
27 | extern int rio_disc_mport(struct rio_mport *mport); | 31 | extern int rio_disc_mport(struct rio_mport *mport); |
@@ -34,6 +38,7 @@ extern int rio_std_route_get_entry(struct rio_mport *mport, u16 destid, | |||
34 | extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, | 38 | extern int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, |
35 | u8 hopcount, u16 table); | 39 | u8 hopcount, u16 table); |
36 | extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); | 40 | extern int rio_set_port_lockout(struct rio_dev *rdev, u32 pnum, int lock); |
41 | extern struct rio_dev *rio_get_comptag(u32 comp_tag, struct rio_dev *from); | ||
37 | 42 | ||
38 | /* Structures internal to the RIO core code */ | 43 | /* Structures internal to the RIO core code */ |
39 | extern struct device_attribute rio_dev_attrs[]; | 44 | extern struct device_attribute rio_dev_attrs[]; |
diff --git a/drivers/rapidio/switches/Kconfig b/drivers/rapidio/switches/Kconfig index 2b4e9b2b6631..f47fee5d4563 100644 --- a/drivers/rapidio/switches/Kconfig +++ b/drivers/rapidio/switches/Kconfig | |||
@@ -20,6 +20,13 @@ config RAPIDIO_TSI568 | |||
20 | ---help--- | 20 | ---help--- |
21 | Includes support for IDT Tsi568 serial RapidIO switch. | 21 | Includes support for IDT Tsi568 serial RapidIO switch. |
22 | 22 | ||
23 | config RAPIDIO_CPS_GEN2 | ||
24 | bool "IDT CPS Gen.2 SRIO switch support" | ||
25 | depends on RAPIDIO | ||
26 | default n | ||
27 | ---help--- | ||
28 | Includes support for ITD CPS Gen.2 serial RapidIO switches. | ||
29 | |||
23 | config RAPIDIO_TSI500 | 30 | config RAPIDIO_TSI500 |
24 | bool "Tsi500 Parallel RapidIO switch support" | 31 | bool "Tsi500 Parallel RapidIO switch support" |
25 | depends on RAPIDIO | 32 | depends on RAPIDIO |
diff --git a/drivers/rapidio/switches/Makefile b/drivers/rapidio/switches/Makefile index fe4adc3e8d5f..48d67a6b98c8 100644 --- a/drivers/rapidio/switches/Makefile +++ b/drivers/rapidio/switches/Makefile | |||
@@ -6,6 +6,7 @@ obj-$(CONFIG_RAPIDIO_TSI57X) += tsi57x.o | |||
6 | obj-$(CONFIG_RAPIDIO_CPS_XX) += idtcps.o | 6 | obj-$(CONFIG_RAPIDIO_CPS_XX) += idtcps.o |
7 | obj-$(CONFIG_RAPIDIO_TSI568) += tsi568.o | 7 | obj-$(CONFIG_RAPIDIO_TSI568) += tsi568.o |
8 | obj-$(CONFIG_RAPIDIO_TSI500) += tsi500.o | 8 | obj-$(CONFIG_RAPIDIO_TSI500) += tsi500.o |
9 | obj-$(CONFIG_RAPIDIO_CPS_GEN2) += idt_gen2.o | ||
9 | 10 | ||
10 | ifeq ($(CONFIG_RAPIDIO_DEBUG),y) | 11 | ifeq ($(CONFIG_RAPIDIO_DEBUG),y) |
11 | EXTRA_CFLAGS += -DDEBUG | 12 | EXTRA_CFLAGS += -DDEBUG |
diff --git a/drivers/rapidio/switches/idt_gen2.c b/drivers/rapidio/switches/idt_gen2.c new file mode 100644 index 000000000000..0bb871cb5c40 --- /dev/null +++ b/drivers/rapidio/switches/idt_gen2.c | |||
@@ -0,0 +1,447 @@ | |||
1 | /* | ||
2 | * IDT CPS Gen.2 Serial RapidIO switch family support | ||
3 | * | ||
4 | * Copyright 2010 Integrated Device Technology, Inc. | ||
5 | * Alexandre Bounine <alexandre.bounine@idt.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
10 | * option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/rio.h> | ||
14 | #include <linux/rio_drv.h> | ||
15 | #include <linux/rio_ids.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include "../rio.h" | ||
18 | |||
19 | #define LOCAL_RTE_CONF_DESTID_SEL 0x010070 | ||
20 | #define LOCAL_RTE_CONF_DESTID_SEL_PSEL 0x0000001f | ||
21 | |||
22 | #define IDT_LT_ERR_REPORT_EN 0x03100c | ||
23 | |||
24 | #define IDT_PORT_ERR_REPORT_EN(n) (0x031044 + (n)*0x40) | ||
25 | #define IDT_PORT_ERR_REPORT_EN_BC 0x03ff04 | ||
26 | |||
27 | #define IDT_PORT_ISERR_REPORT_EN(n) (0x03104C + (n)*0x40) | ||
28 | #define IDT_PORT_ISERR_REPORT_EN_BC 0x03ff0c | ||
29 | #define IDT_PORT_INIT_TX_ACQUIRED 0x00000020 | ||
30 | |||
31 | #define IDT_LANE_ERR_REPORT_EN(n) (0x038010 + (n)*0x100) | ||
32 | #define IDT_LANE_ERR_REPORT_EN_BC 0x03ff10 | ||
33 | |||
34 | #define IDT_DEV_CTRL_1 0xf2000c | ||
35 | #define IDT_DEV_CTRL_1_GENPW 0x02000000 | ||
36 | #define IDT_DEV_CTRL_1_PRSTBEH 0x00000001 | ||
37 | |||
38 | #define IDT_CFGBLK_ERR_CAPTURE_EN 0x020008 | ||
39 | #define IDT_CFGBLK_ERR_REPORT 0xf20014 | ||
40 | #define IDT_CFGBLK_ERR_REPORT_GENPW 0x00000002 | ||
41 | |||
42 | #define IDT_AUX_PORT_ERR_CAP_EN 0x020000 | ||
43 | #define IDT_AUX_ERR_REPORT_EN 0xf20018 | ||
44 | #define IDT_AUX_PORT_ERR_LOG_I2C 0x00000002 | ||
45 | #define IDT_AUX_PORT_ERR_LOG_JTAG 0x00000001 | ||
46 | |||
47 | #define IDT_ISLTL_ADDRESS_CAP 0x021014 | ||
48 | |||
49 | #define IDT_RIO_DOMAIN 0xf20020 | ||
50 | #define IDT_RIO_DOMAIN_MASK 0x000000ff | ||
51 | |||
52 | #define IDT_PW_INFO_CSR 0xf20024 | ||
53 | |||
54 | #define IDT_SOFT_RESET 0xf20040 | ||
55 | #define IDT_SOFT_RESET_REQ 0x00030097 | ||
56 | |||
57 | #define IDT_I2C_MCTRL 0xf20050 | ||
58 | #define IDT_I2C_MCTRL_GENPW 0x04000000 | ||
59 | |||
60 | #define IDT_JTAG_CTRL 0xf2005c | ||
61 | #define IDT_JTAG_CTRL_GENPW 0x00000002 | ||
62 | |||
63 | #define IDT_LANE_CTRL(n) (0xff8000 + (n)*0x100) | ||
64 | #define IDT_LANE_CTRL_BC 0xffff00 | ||
65 | #define IDT_LANE_CTRL_GENPW 0x00200000 | ||
66 | #define IDT_LANE_DFE_1_BC 0xffff18 | ||
67 | #define IDT_LANE_DFE_2_BC 0xffff1c | ||
68 | |||
69 | #define IDT_PORT_OPS(n) (0xf40004 + (n)*0x100) | ||
70 | #define IDT_PORT_OPS_GENPW 0x08000000 | ||
71 | #define IDT_PORT_OPS_PL_ELOG 0x00000040 | ||
72 | #define IDT_PORT_OPS_LL_ELOG 0x00000020 | ||
73 | #define IDT_PORT_OPS_LT_ELOG 0x00000010 | ||
74 | #define IDT_PORT_OPS_BC 0xf4ff04 | ||
75 | |||
76 | #define IDT_PORT_ISERR_DET(n) (0xf40008 + (n)*0x100) | ||
77 | |||
78 | #define IDT_ERR_CAP 0xfd0000 | ||
79 | #define IDT_ERR_CAP_LOG_OVERWR 0x00000004 | ||
80 | |||
81 | #define IDT_ERR_RD 0xfd0004 | ||
82 | |||
83 | #define IDT_DEFAULT_ROUTE 0xde | ||
84 | #define IDT_NO_ROUTE 0xdf | ||
85 | |||
86 | static int | ||
87 | idtg2_route_add_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
88 | u16 table, u16 route_destid, u8 route_port) | ||
89 | { | ||
90 | /* | ||
91 | * Select routing table to update | ||
92 | */ | ||
93 | if (table == RIO_GLOBAL_TABLE) | ||
94 | table = 0; | ||
95 | else | ||
96 | table++; | ||
97 | |||
98 | rio_mport_write_config_32(mport, destid, hopcount, | ||
99 | LOCAL_RTE_CONF_DESTID_SEL, table); | ||
100 | |||
101 | /* | ||
102 | * Program destination port for the specified destID | ||
103 | */ | ||
104 | rio_mport_write_config_32(mport, destid, hopcount, | ||
105 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, | ||
106 | (u32)route_destid); | ||
107 | |||
108 | rio_mport_write_config_32(mport, destid, hopcount, | ||
109 | RIO_STD_RTE_CONF_PORT_SEL_CSR, | ||
110 | (u32)route_port); | ||
111 | udelay(10); | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int | ||
117 | idtg2_route_get_entry(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
118 | u16 table, u16 route_destid, u8 *route_port) | ||
119 | { | ||
120 | u32 result; | ||
121 | |||
122 | /* | ||
123 | * Select routing table to read | ||
124 | */ | ||
125 | if (table == RIO_GLOBAL_TABLE) | ||
126 | table = 0; | ||
127 | else | ||
128 | table++; | ||
129 | |||
130 | rio_mport_write_config_32(mport, destid, hopcount, | ||
131 | LOCAL_RTE_CONF_DESTID_SEL, table); | ||
132 | |||
133 | rio_mport_write_config_32(mport, destid, hopcount, | ||
134 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, | ||
135 | route_destid); | ||
136 | |||
137 | rio_mport_read_config_32(mport, destid, hopcount, | ||
138 | RIO_STD_RTE_CONF_PORT_SEL_CSR, &result); | ||
139 | |||
140 | if (IDT_DEFAULT_ROUTE == (u8)result || IDT_NO_ROUTE == (u8)result) | ||
141 | *route_port = RIO_INVALID_ROUTE; | ||
142 | else | ||
143 | *route_port = (u8)result; | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static int | ||
149 | idtg2_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
150 | u16 table) | ||
151 | { | ||
152 | u32 i; | ||
153 | |||
154 | /* | ||
155 | * Select routing table to read | ||
156 | */ | ||
157 | if (table == RIO_GLOBAL_TABLE) | ||
158 | table = 0; | ||
159 | else | ||
160 | table++; | ||
161 | |||
162 | rio_mport_write_config_32(mport, destid, hopcount, | ||
163 | LOCAL_RTE_CONF_DESTID_SEL, table); | ||
164 | |||
165 | for (i = RIO_STD_RTE_CONF_EXTCFGEN; | ||
166 | i <= (RIO_STD_RTE_CONF_EXTCFGEN | 0xff);) { | ||
167 | rio_mport_write_config_32(mport, destid, hopcount, | ||
168 | RIO_STD_RTE_CONF_DESTID_SEL_CSR, i); | ||
169 | rio_mport_write_config_32(mport, destid, hopcount, | ||
170 | RIO_STD_RTE_CONF_PORT_SEL_CSR, | ||
171 | (IDT_DEFAULT_ROUTE << 24) | (IDT_DEFAULT_ROUTE << 16) | | ||
172 | (IDT_DEFAULT_ROUTE << 8) | IDT_DEFAULT_ROUTE); | ||
173 | i += 4; | ||
174 | } | ||
175 | |||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | |||
180 | static int | ||
181 | idtg2_set_domain(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
182 | u8 sw_domain) | ||
183 | { | ||
184 | /* | ||
185 | * Switch domain configuration operates only at global level | ||
186 | */ | ||
187 | rio_mport_write_config_32(mport, destid, hopcount, | ||
188 | IDT_RIO_DOMAIN, (u32)sw_domain); | ||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | static int | ||
193 | idtg2_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, | ||
194 | u8 *sw_domain) | ||
195 | { | ||
196 | u32 regval; | ||
197 | |||
198 | /* | ||
199 | * Switch domain configuration operates only at global level | ||
200 | */ | ||
201 | rio_mport_read_config_32(mport, destid, hopcount, | ||
202 | IDT_RIO_DOMAIN, ®val); | ||
203 | |||
204 | *sw_domain = (u8)(regval & 0xff); | ||
205 | |||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static int | ||
210 | idtg2_em_init(struct rio_dev *rdev) | ||
211 | { | ||
212 | struct rio_mport *mport = rdev->net->hport; | ||
213 | u16 destid = rdev->rswitch->destid; | ||
214 | u8 hopcount = rdev->rswitch->hopcount; | ||
215 | u32 regval; | ||
216 | int i, tmp; | ||
217 | |||
218 | /* | ||
219 | * This routine performs device-specific initialization only. | ||
220 | * All standard EM configuration should be performed at upper level. | ||
221 | */ | ||
222 | |||
223 | pr_debug("RIO: %s [%d:%d]\n", __func__, destid, hopcount); | ||
224 | |||
225 | /* Set Port-Write info CSR: PRIO=3 and CRF=1 */ | ||
226 | rio_mport_write_config_32(mport, destid, hopcount, | ||
227 | IDT_PW_INFO_CSR, 0x0000e000); | ||
228 | |||
229 | /* | ||
230 | * Configure LT LAYER error reporting. | ||
231 | */ | ||
232 | |||
233 | /* Enable standard (RIO.p8) error reporting */ | ||
234 | rio_mport_write_config_32(mport, destid, hopcount, | ||
235 | IDT_LT_ERR_REPORT_EN, | ||
236 | REM_LTL_ERR_ILLTRAN | REM_LTL_ERR_UNSOLR | | ||
237 | REM_LTL_ERR_UNSUPTR); | ||
238 | |||
239 | /* Use Port-Writes for LT layer error reporting. | ||
240 | * Enable per-port reset | ||
241 | */ | ||
242 | rio_mport_read_config_32(mport, destid, hopcount, | ||
243 | IDT_DEV_CTRL_1, ®val); | ||
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); | ||
247 | |||
248 | /* | ||
249 | * Configure PORT error reporting. | ||
250 | */ | ||
251 | |||
252 | /* Report all RIO.p8 errors supported by device */ | ||
253 | rio_mport_write_config_32(mport, destid, hopcount, | ||
254 | IDT_PORT_ERR_REPORT_EN_BC, 0x807e8037); | ||
255 | |||
256 | /* Configure reporting of implementation specific errors/events */ | ||
257 | rio_mport_write_config_32(mport, destid, hopcount, | ||
258 | IDT_PORT_ISERR_REPORT_EN_BC, IDT_PORT_INIT_TX_ACQUIRED); | ||
259 | |||
260 | /* Use Port-Writes for port error reporting and enable error logging */ | ||
261 | tmp = RIO_GET_TOTAL_PORTS(rdev->swpinfo); | ||
262 | for (i = 0; i < tmp; i++) { | ||
263 | rio_mport_read_config_32(mport, destid, hopcount, | ||
264 | IDT_PORT_OPS(i), ®val); | ||
265 | rio_mport_write_config_32(mport, destid, hopcount, | ||
266 | IDT_PORT_OPS(i), regval | IDT_PORT_OPS_GENPW | | ||
267 | IDT_PORT_OPS_PL_ELOG | | ||
268 | IDT_PORT_OPS_LL_ELOG | | ||
269 | IDT_PORT_OPS_LT_ELOG); | ||
270 | } | ||
271 | /* Overwrite error log if full */ | ||
272 | rio_mport_write_config_32(mport, destid, hopcount, | ||
273 | IDT_ERR_CAP, IDT_ERR_CAP_LOG_OVERWR); | ||
274 | |||
275 | /* | ||
276 | * Configure LANE error reporting. | ||
277 | */ | ||
278 | |||
279 | /* Disable line error reporting */ | ||
280 | rio_mport_write_config_32(mport, destid, hopcount, | ||
281 | IDT_LANE_ERR_REPORT_EN_BC, 0); | ||
282 | |||
283 | /* Use Port-Writes for lane error reporting (when enabled) | ||
284 | * (do per-lane update because lanes may have different configuration) | ||
285 | */ | ||
286 | tmp = (rdev->did == RIO_DID_IDTCPS1848) ? 48 : 16; | ||
287 | for (i = 0; i < tmp; i++) { | ||
288 | rio_mport_read_config_32(mport, destid, hopcount, | ||
289 | IDT_LANE_CTRL(i), ®val); | ||
290 | rio_mport_write_config_32(mport, destid, hopcount, | ||
291 | IDT_LANE_CTRL(i), regval | IDT_LANE_CTRL_GENPW); | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | * Configure AUX error reporting. | ||
296 | */ | ||
297 | |||
298 | /* Disable JTAG and I2C Error capture */ | ||
299 | rio_mport_write_config_32(mport, destid, hopcount, | ||
300 | IDT_AUX_PORT_ERR_CAP_EN, 0); | ||
301 | |||
302 | /* Disable JTAG and I2C Error reporting/logging */ | ||
303 | rio_mport_write_config_32(mport, destid, hopcount, | ||
304 | IDT_AUX_ERR_REPORT_EN, 0); | ||
305 | |||
306 | /* Disable Port-Write notification from JTAG */ | ||
307 | rio_mport_write_config_32(mport, destid, hopcount, | ||
308 | IDT_JTAG_CTRL, 0); | ||
309 | |||
310 | /* Disable Port-Write notification from I2C */ | ||
311 | rio_mport_read_config_32(mport, destid, hopcount, | ||
312 | IDT_I2C_MCTRL, ®val); | ||
313 | rio_mport_write_config_32(mport, destid, hopcount, | ||
314 | IDT_I2C_MCTRL, | ||
315 | regval & ~IDT_I2C_MCTRL_GENPW); | ||
316 | |||
317 | /* | ||
318 | * Configure CFG_BLK error reporting. | ||
319 | */ | ||
320 | |||
321 | /* Disable Configuration Block error capture */ | ||
322 | rio_mport_write_config_32(mport, destid, hopcount, | ||
323 | IDT_CFGBLK_ERR_CAPTURE_EN, 0); | ||
324 | |||
325 | /* Disable Port-Writes for Configuration Block error reporting */ | ||
326 | rio_mport_read_config_32(mport, destid, hopcount, | ||
327 | IDT_CFGBLK_ERR_REPORT, ®val); | ||
328 | rio_mport_write_config_32(mport, destid, hopcount, | ||
329 | IDT_CFGBLK_ERR_REPORT, | ||
330 | regval & ~IDT_CFGBLK_ERR_REPORT_GENPW); | ||
331 | |||
332 | /* set TVAL = ~50us */ | ||
333 | rio_mport_write_config_32(mport, destid, hopcount, | ||
334 | rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); | ||
335 | |||
336 | return 0; | ||
337 | } | ||
338 | |||
339 | static int | ||
340 | idtg2_em_handler(struct rio_dev *rdev, u8 portnum) | ||
341 | { | ||
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; | ||
346 | |||
347 | rio_mport_read_config_32(mport, destid, hopcount, | ||
348 | rdev->em_efptr + RIO_EM_LTL_ERR_DETECT, &em_ltlerrdet); | ||
349 | if (em_ltlerrdet) { | ||
350 | /* Service Logical/Transport Layer Error(s) */ | ||
351 | if (em_ltlerrdet & REM_LTL_ERR_IMPSPEC) { | ||
352 | /* Implementation specific error reported */ | ||
353 | rio_mport_read_config_32(mport, destid, hopcount, | ||
354 | IDT_ISLTL_ADDRESS_CAP, ®val); | ||
355 | |||
356 | pr_debug("RIO: %s Implementation Specific LTL errors" \ | ||
357 | " 0x%x @(0x%x)\n", | ||
358 | rio_name(rdev), em_ltlerrdet, regval); | ||
359 | |||
360 | /* Clear implementation specific address capture CSR */ | ||
361 | rio_mport_write_config_32(mport, destid, hopcount, | ||
362 | IDT_ISLTL_ADDRESS_CAP, 0); | ||
363 | |||
364 | } | ||
365 | } | ||
366 | |||
367 | rio_mport_read_config_32(mport, destid, hopcount, | ||
368 | rdev->em_efptr + RIO_EM_PN_ERR_DETECT(portnum), &em_perrdet); | ||
369 | if (em_perrdet) { | ||
370 | /* Service Port-Level Error(s) */ | ||
371 | if (em_perrdet & REM_PED_IMPL_SPEC) { | ||
372 | /* Implementation Specific port error reported */ | ||
373 | |||
374 | /* Get IS errors reported */ | ||
375 | rio_mport_read_config_32(mport, destid, hopcount, | ||
376 | IDT_PORT_ISERR_DET(portnum), ®val); | ||
377 | |||
378 | pr_debug("RIO: %s Implementation Specific Port" \ | ||
379 | " errors 0x%x\n", rio_name(rdev), regval); | ||
380 | |||
381 | /* Clear all implementation specific events */ | ||
382 | rio_mport_write_config_32(mport, destid, hopcount, | ||
383 | IDT_PORT_ISERR_DET(portnum), 0); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | static ssize_t | ||
391 | idtg2_show_errlog(struct device *dev, struct device_attribute *attr, char *buf) | ||
392 | { | ||
393 | 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; | ||
398 | u32 regval; | ||
399 | |||
400 | while (!rio_mport_read_config_32(mport, destid, hopcount, | ||
401 | IDT_ERR_RD, ®val)) { | ||
402 | if (!regval) /* 0 = end of log */ | ||
403 | break; | ||
404 | len += snprintf(buf + len, PAGE_SIZE - len, | ||
405 | "%08x\n", regval); | ||
406 | if (len >= (PAGE_SIZE - 10)) | ||
407 | break; | ||
408 | } | ||
409 | |||
410 | return len; | ||
411 | } | ||
412 | |||
413 | static DEVICE_ATTR(errlog, S_IRUGO, idtg2_show_errlog, NULL); | ||
414 | |||
415 | static int idtg2_sysfs(struct rio_dev *rdev, int create) | ||
416 | { | ||
417 | struct device *dev = &rdev->dev; | ||
418 | int err = 0; | ||
419 | |||
420 | if (create == RIO_SW_SYSFS_CREATE) { | ||
421 | /* Initialize sysfs entries */ | ||
422 | err = device_create_file(dev, &dev_attr_errlog); | ||
423 | if (err) | ||
424 | dev_err(dev, "Unable create sysfs errlog file\n"); | ||
425 | } else | ||
426 | device_remove_file(dev, &dev_attr_errlog); | ||
427 | |||
428 | return err; | ||
429 | } | ||
430 | |||
431 | static int idtg2_switch_init(struct rio_dev *rdev, int do_enum) | ||
432 | { | ||
433 | pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); | ||
434 | rdev->rswitch->add_entry = idtg2_route_add_entry; | ||
435 | rdev->rswitch->get_entry = idtg2_route_get_entry; | ||
436 | rdev->rswitch->clr_table = idtg2_route_clr_table; | ||
437 | rdev->rswitch->set_domain = idtg2_set_domain; | ||
438 | rdev->rswitch->get_domain = idtg2_get_domain; | ||
439 | rdev->rswitch->em_init = idtg2_em_init; | ||
440 | rdev->rswitch->em_handle = idtg2_em_handler; | ||
441 | rdev->rswitch->sw_sysfs = idtg2_sysfs; | ||
442 | |||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS1848, idtg2_switch_init); | ||
447 | DECLARE_RIO_SWITCH_INIT(RIO_VID_IDT, RIO_DID_IDTCPS1616, idtg2_switch_init); | ||
diff --git a/drivers/rapidio/switches/idtcps.c b/drivers/rapidio/switches/idtcps.c index 2c790c144f89..fc9f6374f759 100644 --- a/drivers/rapidio/switches/idtcps.c +++ b/drivers/rapidio/switches/idtcps.c | |||
@@ -117,6 +117,10 @@ idtcps_get_domain(struct rio_mport *mport, u16 destid, u8 hopcount, | |||
117 | 117 | ||
118 | static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) | 118 | static 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 | |||
120 | pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); | 124 | pr_debug("RIO: %s for %s\n", __func__, rio_name(rdev)); |
121 | rdev->rswitch->add_entry = idtcps_route_add_entry; | 125 | rdev->rswitch->add_entry = idtcps_route_add_entry; |
122 | rdev->rswitch->get_entry = idtcps_route_get_entry; | 126 | rdev->rswitch->get_entry = idtcps_route_get_entry; |
@@ -126,6 +130,12 @@ static int idtcps_switch_init(struct rio_dev *rdev, int do_enum) | |||
126 | rdev->rswitch->em_init = NULL; | 130 | rdev->rswitch->em_init = NULL; |
127 | rdev->rswitch->em_handle = NULL; | 131 | rdev->rswitch->em_handle = NULL; |
128 | 132 | ||
133 | if (do_enum) { | ||
134 | /* set TVAL = ~50us */ | ||
135 | rio_mport_write_config_32(mport, destid, hopcount, | ||
136 | rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x8e << 8); | ||
137 | } | ||
138 | |||
129 | return 0; | 139 | return 0; |
130 | } | 140 | } |
131 | 141 | ||
diff --git a/drivers/rapidio/switches/tsi568.c b/drivers/rapidio/switches/tsi568.c index f7fd7898606e..b9a389b9f812 100644 --- a/drivers/rapidio/switches/tsi568.c +++ b/drivers/rapidio/switches/tsi568.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) | 29 | #define SPP_ROUTE_CFG_DESTID(n) (0x11070 + 0x100*n) |
30 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) | 30 | #define SPP_ROUTE_CFG_PORT(n) (0x11074 + 0x100*n) |
31 | 31 | ||
32 | #define TSI568_SP_MODE_BC 0x10004 | 32 | #define TSI568_SP_MODE(n) (0x11004 + 0x100*n) |
33 | #define TSI568_SP_MODE_PW_DIS 0x08000000 | 33 | #define TSI568_SP_MODE_PW_DIS 0x08000000 |
34 | 34 | ||
35 | static int | 35 | static int |
@@ -117,14 +117,19 @@ tsi568_em_init(struct rio_dev *rdev) | |||
117 | u16 destid = rdev->rswitch->destid; | 117 | u16 destid = rdev->rswitch->destid; |
118 | u8 hopcount = rdev->rswitch->hopcount; | 118 | u8 hopcount = rdev->rswitch->hopcount; |
119 | u32 regval; | 119 | u32 regval; |
120 | int portnum; | ||
120 | 121 | ||
121 | pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount); | 122 | pr_debug("TSI568 %s [%d:%d]\n", __func__, destid, hopcount); |
122 | 123 | ||
123 | /* Make sure that Port-Writes are disabled (for all ports) */ | 124 | /* Make sure that Port-Writes are disabled (for all ports) */ |
124 | rio_mport_read_config_32(mport, destid, hopcount, | 125 | for (portnum = 0; |
125 | TSI568_SP_MODE_BC, ®val); | 126 | portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { |
126 | rio_mport_write_config_32(mport, destid, hopcount, | 127 | rio_mport_read_config_32(mport, destid, hopcount, |
127 | TSI568_SP_MODE_BC, regval | TSI568_SP_MODE_PW_DIS); | 128 | TSI568_SP_MODE(portnum), ®val); |
129 | rio_mport_write_config_32(mport, destid, hopcount, | ||
130 | TSI568_SP_MODE(portnum), | ||
131 | regval | TSI568_SP_MODE_PW_DIS); | ||
132 | } | ||
128 | 133 | ||
129 | return 0; | 134 | return 0; |
130 | } | 135 | } |
diff --git a/drivers/rapidio/switches/tsi57x.c b/drivers/rapidio/switches/tsi57x.c index d34df722d95f..2003fb63c404 100644 --- a/drivers/rapidio/switches/tsi57x.c +++ b/drivers/rapidio/switches/tsi57x.c | |||
@@ -166,7 +166,8 @@ tsi57x_em_init(struct rio_dev *rdev) | |||
166 | 166 | ||
167 | pr_debug("TSI578 %s [%d:%d]\n", __func__, destid, hopcount); | 167 | pr_debug("TSI578 %s [%d:%d]\n", __func__, destid, hopcount); |
168 | 168 | ||
169 | for (portnum = 0; portnum < 16; portnum++) { | 169 | for (portnum = 0; |
170 | portnum < RIO_GET_TOTAL_PORTS(rdev->swpinfo); portnum++) { | ||
170 | /* Make sure that Port-Writes are enabled (for all ports) */ | 171 | /* Make sure that Port-Writes are enabled (for all ports) */ |
171 | rio_mport_read_config_32(mport, destid, hopcount, | 172 | rio_mport_read_config_32(mport, destid, hopcount, |
172 | TSI578_SP_MODE(portnum), ®val); | 173 | TSI578_SP_MODE(portnum), ®val); |
@@ -205,6 +206,10 @@ tsi57x_em_init(struct rio_dev *rdev) | |||
205 | portnum++; | 206 | portnum++; |
206 | } | 207 | } |
207 | 208 | ||
209 | /* set TVAL = ~50us */ | ||
210 | rio_mport_write_config_32(mport, destid, hopcount, | ||
211 | rdev->phys_efptr + RIO_PORT_LINKTO_CTL_CSR, 0x9a << 8); | ||
212 | |||
208 | return 0; | 213 | return 0; |
209 | } | 214 | } |
210 | 215 | ||