diff options
author | Zhang Wei <wei.zhang@freescale.com> | 2008-04-18 16:33:42 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-04-29 05:40:28 -0400 |
commit | e042323607f5c14844b1c59aebbca8d1251c7d89 (patch) | |
tree | 10c9eac3d5146f3611af9220740e4ec27bf2ade0 /drivers/rapidio/rio-scan.c | |
parent | cc2bb6968a2c842149d285d77cb35200d2d37b15 (diff) |
[RAPIDIO] Auto-probe the RapidIO system size
The RapidIO system size will auto probe in RIO setup. The route table
and rionet_active in rionet.c are changed to be allocated dynamically
according to the size of the system.
Signed-off-by: Zhang Wei <wei.zhang@freescale.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/rapidio/rio-scan.c')
-rw-r--r-- | drivers/rapidio/rio-scan.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 44420723a359..a926c896475e 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
@@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) | |||
73 | 73 | ||
74 | rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, &result); | 74 | rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, &result); |
75 | 75 | ||
76 | return RIO_GET_DID(result); | 76 | return RIO_GET_DID(port->sys_size, result); |
77 | } | 77 | } |
78 | 78 | ||
79 | /** | 79 | /** |
@@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) | |||
88 | static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did) | 88 | static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did) |
89 | { | 89 | { |
90 | rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR, | 90 | rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR, |
91 | RIO_SET_DID(did)); | 91 | RIO_SET_DID(port->sys_size, did)); |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
@@ -100,7 +100,8 @@ static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u | |||
100 | */ | 100 | */ |
101 | static void rio_local_set_device_id(struct rio_mport *port, u16 did) | 101 | static void rio_local_set_device_id(struct rio_mport *port, u16 did) |
102 | { | 102 | { |
103 | rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(did)); | 103 | rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(port->sys_size, |
104 | did)); | ||
104 | } | 105 | } |
105 | 106 | ||
106 | /** | 107 | /** |
@@ -350,8 +351,18 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, | |||
350 | rswitch->switchid = next_switchid; | 351 | rswitch->switchid = next_switchid; |
351 | rswitch->hopcount = hopcount; | 352 | rswitch->hopcount = hopcount; |
352 | rswitch->destid = destid; | 353 | rswitch->destid = destid; |
354 | rswitch->route_table = kzalloc(sizeof(u8)* | ||
355 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), | ||
356 | GFP_KERNEL); | ||
357 | if (!rswitch->route_table) { | ||
358 | kfree(rdev); | ||
359 | rdev = NULL; | ||
360 | kfree(rswitch); | ||
361 | goto out; | ||
362 | } | ||
353 | /* Initialize switch route table */ | 363 | /* Initialize switch route table */ |
354 | for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++) | 364 | for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size); |
365 | rdid++) | ||
355 | rswitch->route_table[rdid] = RIO_INVALID_ROUTE; | 366 | rswitch->route_table[rdid] = RIO_INVALID_ROUTE; |
356 | rdev->rswitch = rswitch; | 367 | rdev->rswitch = rswitch; |
357 | sprintf(rio_name(rdev), "%02x:s:%04x", rdev->net->id, | 368 | sprintf(rio_name(rdev), "%02x:s:%04x", rdev->net->id, |
@@ -480,7 +491,7 @@ static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount) | |||
480 | { | 491 | { |
481 | u32 result; | 492 | u32 result; |
482 | 493 | ||
483 | rio_mport_read_config_32(port, RIO_ANY_DESTID, hopcount, | 494 | rio_mport_read_config_32(port, RIO_ANY_DESTID(port->sys_size), hopcount, |
484 | RIO_HOST_DID_LOCK_CSR, &result); | 495 | RIO_HOST_DID_LOCK_CSR, &result); |
485 | 496 | ||
486 | return (u16) (result & 0xffff); | 497 | return (u16) (result & 0xffff); |
@@ -571,14 +582,16 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
571 | } | 582 | } |
572 | 583 | ||
573 | /* Attempt to acquire device lock */ | 584 | /* Attempt to acquire device lock */ |
574 | rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount, | 585 | rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size), |
586 | hopcount, | ||
575 | RIO_HOST_DID_LOCK_CSR, port->host_deviceid); | 587 | RIO_HOST_DID_LOCK_CSR, port->host_deviceid); |
576 | while ((tmp = rio_get_host_deviceid_lock(port, hopcount)) | 588 | while ((tmp = rio_get_host_deviceid_lock(port, hopcount)) |
577 | < port->host_deviceid) { | 589 | < port->host_deviceid) { |
578 | /* Delay a bit */ | 590 | /* Delay a bit */ |
579 | mdelay(1); | 591 | mdelay(1); |
580 | /* Attempt to acquire device lock again */ | 592 | /* Attempt to acquire device lock again */ |
581 | rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount, | 593 | rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size), |
594 | hopcount, | ||
582 | RIO_HOST_DID_LOCK_CSR, | 595 | RIO_HOST_DID_LOCK_CSR, |
583 | port->host_deviceid); | 596 | port->host_deviceid); |
584 | } | 597 | } |
@@ -590,7 +603,9 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
590 | } | 603 | } |
591 | 604 | ||
592 | /* Setup new RIO device */ | 605 | /* Setup new RIO device */ |
593 | if ((rdev = rio_setup_device(net, port, RIO_ANY_DESTID, hopcount, 1))) { | 606 | rdev = rio_setup_device(net, port, RIO_ANY_DESTID(port->sys_size), |
607 | hopcount, 1); | ||
608 | if (rdev) { | ||
594 | /* Add device to the global and bus/net specific list. */ | 609 | /* Add device to the global and bus/net specific list. */ |
595 | list_add_tail(&rdev->net_list, &net->devices); | 610 | list_add_tail(&rdev->net_list, &net->devices); |
596 | } else | 611 | } else |
@@ -598,7 +613,8 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
598 | 613 | ||
599 | if (rio_is_switch(rdev)) { | 614 | if (rio_is_switch(rdev)) { |
600 | next_switchid++; | 615 | next_switchid++; |
601 | sw_inport = rio_get_swpinfo_inport(port, RIO_ANY_DESTID, hopcount); | 616 | sw_inport = rio_get_swpinfo_inport(port, |
617 | RIO_ANY_DESTID(port->sys_size), hopcount); | ||
602 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, | 618 | rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, |
603 | port->host_deviceid, sw_inport); | 619 | port->host_deviceid, sw_inport); |
604 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; | 620 | rdev->rswitch->route_table[port->host_deviceid] = sw_inport; |
@@ -612,7 +628,8 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
612 | } | 628 | } |
613 | 629 | ||
614 | num_ports = | 630 | num_ports = |
615 | rio_get_swpinfo_tports(port, RIO_ANY_DESTID, hopcount); | 631 | rio_get_swpinfo_tports(port, RIO_ANY_DESTID(port->sys_size), |
632 | hopcount); | ||
616 | pr_debug( | 633 | pr_debug( |
617 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", | 634 | "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", |
618 | rio_name(rdev), rdev->vid, rdev->did, num_ports); | 635 | rio_name(rdev), rdev->vid, rdev->did, num_ports); |
@@ -624,13 +641,15 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, | |||
624 | cur_destid = next_destid; | 641 | cur_destid = next_destid; |
625 | 642 | ||
626 | if (rio_sport_is_active | 643 | if (rio_sport_is_active |
627 | (port, RIO_ANY_DESTID, hopcount, port_num)) { | 644 | (port, RIO_ANY_DESTID(port->sys_size), hopcount, |
645 | port_num)) { | ||
628 | pr_debug( | 646 | pr_debug( |
629 | "RIO: scanning device on port %d\n", | 647 | "RIO: scanning device on port %d\n", |
630 | port_num); | 648 | port_num); |
631 | rio_route_add_entry(port, rdev->rswitch, | 649 | rio_route_add_entry(port, rdev->rswitch, |
632 | RIO_GLOBAL_TABLE, | 650 | RIO_GLOBAL_TABLE, |
633 | RIO_ANY_DESTID, port_num); | 651 | RIO_ANY_DESTID(port->sys_size), |
652 | port_num); | ||
634 | 653 | ||
635 | if (rio_enum_peer(net, port, hopcount + 1) < 0) | 654 | if (rio_enum_peer(net, port, hopcount + 1) < 0) |
636 | return -1; | 655 | return -1; |
@@ -735,7 +754,8 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, | |||
735 | pr_debug( | 754 | pr_debug( |
736 | "RIO: scanning device on port %d\n", | 755 | "RIO: scanning device on port %d\n", |
737 | port_num); | 756 | port_num); |
738 | for (ndestid = 0; ndestid < RIO_ANY_DESTID; | 757 | for (ndestid = 0; |
758 | ndestid < RIO_ANY_DESTID(port->sys_size); | ||
739 | ndestid++) { | 759 | ndestid++) { |
740 | rio_route_get_entry(port, rdev->rswitch, | 760 | rio_route_get_entry(port, rdev->rswitch, |
741 | RIO_GLOBAL_TABLE, | 761 | RIO_GLOBAL_TABLE, |
@@ -917,7 +937,9 @@ static void rio_build_route_tables(void) | |||
917 | 937 | ||
918 | list_for_each_entry(rdev, &rio_devices, global_list) | 938 | list_for_each_entry(rdev, &rio_devices, global_list) |
919 | if (rio_is_switch(rdev)) | 939 | if (rio_is_switch(rdev)) |
920 | for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) { | 940 | for (i = 0; |
941 | i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); | ||
942 | i++) { | ||
921 | if (rio_route_get_entry | 943 | if (rio_route_get_entry |
922 | (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE, | 944 | (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE, |
923 | i, &sport) < 0) | 945 | i, &sport) < 0) |
@@ -981,7 +1003,8 @@ int rio_disc_mport(struct rio_mport *mport) | |||
981 | del_timer_sync(&rio_enum_timer); | 1003 | del_timer_sync(&rio_enum_timer); |
982 | 1004 | ||
983 | pr_debug("done\n"); | 1005 | pr_debug("done\n"); |
984 | if (rio_disc_peer(net, mport, RIO_ANY_DESTID, 0) < 0) { | 1006 | if (rio_disc_peer(net, mport, RIO_ANY_DESTID(mport->sys_size), |
1007 | 0) < 0) { | ||
985 | printk(KERN_INFO | 1008 | printk(KERN_INFO |
986 | "RIO: master port %d device has failed discovery\n", | 1009 | "RIO: master port %d device has failed discovery\n", |
987 | mport->id); | 1010 | mport->id); |