- /*******************************************************\
- * Check we have such an entry *
- \*******************************************************/
- if(speed >= numspeeds) return(HAD_ERROR); /* illegal speed */
-
- /*******************************************************\
- * Set the dma-speed *
- \*******************************************************/
- aha_cmd(unit,1, 0, 0, 0, AHA_SPEED_SET,aha_bus_speeds[speed].arg);
-
- /*******************************************************\
- * put the test data into the buffer and calculate *
- * it's address. Read it onto the board *
- \*******************************************************/
- strcpy(aha_scratch_buf,aha_test_string);
- lto3b(KVTOPHYS(aha_scratch_buf),ad);
-
- aha_cmd(unit,3, 0, 0, 0, AHA_WRITE_FIFO, ad[0], ad[1], ad[2]);
-
- /*******************************************************\
- * clear the buffer then copy the contents back from the *
- * board. *
- \*******************************************************/
- bzero(aha_scratch_buf,54); /* 54 bytes transfered by test */
-
- aha_cmd(unit,3, 0, 0, 0, AHA_READ_FIFO, ad[0], ad[1], ad[2]);
-
- /*******************************************************\
- * Compare the original data and the final data and *
- * return the correct value depending upon the result *
- \*******************************************************/
- if(strcmp(aha_test_string,aha_scratch_buf))
- { /* copy failed.. assume too fast */
- return(0);
- }
- else
- { /* copy succeded assume speed ok */
- return(aha_bus_speeds[speed].nsecs);
+ lastworking = -1;
+ speed = 7;
+ while (1) {
+ retval = aha_bus_speed_check(unit,speed);
+ if(retval != 0) {
+ lastworking = speed;
+ }
+ if((retval == 0) || (speed == 0)) {
+ if(lastworking == -1) {
+ printf("No working bus speed for aha154X\n");
+ return 0;
+ }
+ printf("%d nSEC ok, using "
+ ,aha_bus_speeds[lastworking].nsecs);
+ if(lastworking == 7) { /* is slowest already */
+ printf("marginal ");
+ } else {
+ lastworking++;
+ }
+ retval2 = aha_bus_speed_check(unit,lastworking);
+ if(retval2 == 0) {
+ printf("test retry failed.. aborting.\n");
+ return 0;
+ }
+ printf("%d nSEC\n",retval2);
+ return retval2 ;
+
+ }
+ speed--;