|  | @@ -30,6 +30,37 @@ FILE_LICENCE ( GPL2_OR_LATER );
 | 
		
	
		
			
			| 30 | 30 |   *
 | 
		
	
		
			
			| 31 | 31 |   */
 | 
		
	
		
			
			| 32 | 32 |  
 | 
		
	
		
			
			|  | 33 | +/**
 | 
		
	
		
			
			|  | 34 | + * Restart autonegotiation
 | 
		
	
		
			
			|  | 35 | + *
 | 
		
	
		
			
			|  | 36 | + * @v mii		MII interface
 | 
		
	
		
			
			|  | 37 | + * @ret rc		Return status code
 | 
		
	
		
			
			|  | 38 | + */
 | 
		
	
		
			
			|  | 39 | +int mii_restart ( struct mii_interface *mii ) {
 | 
		
	
		
			
			|  | 40 | +	int bmcr;
 | 
		
	
		
			
			|  | 41 | +	int rc;
 | 
		
	
		
			
			|  | 42 | +
 | 
		
	
		
			
			|  | 43 | +	/* Read BMCR */
 | 
		
	
		
			
			|  | 44 | +	bmcr = mii_read ( mii, MII_BMCR );
 | 
		
	
		
			
			|  | 45 | +	if ( bmcr < 0 ) {
 | 
		
	
		
			
			|  | 46 | +		rc = bmcr;
 | 
		
	
		
			
			|  | 47 | +		DBGC ( mii, "MII %p could not read BMCR: %s\n",
 | 
		
	
		
			
			|  | 48 | +		       mii, strerror ( rc ) );
 | 
		
	
		
			
			|  | 49 | +		return rc;
 | 
		
	
		
			
			|  | 50 | +	}
 | 
		
	
		
			
			|  | 51 | +
 | 
		
	
		
			
			|  | 52 | +	/* Enable and restart autonegotiation */
 | 
		
	
		
			
			|  | 53 | +	bmcr |= ( BMCR_ANENABLE | BMCR_ANRESTART );
 | 
		
	
		
			
			|  | 54 | +	if ( ( rc = mii_write ( mii, MII_BMCR, bmcr ) ) != 0 ) {
 | 
		
	
		
			
			|  | 55 | +		DBGC ( mii, "MII %p could not write BMCR: %s\n",
 | 
		
	
		
			
			|  | 56 | +		       mii, strerror ( rc ) );
 | 
		
	
		
			
			|  | 57 | +		return rc;
 | 
		
	
		
			
			|  | 58 | +	}
 | 
		
	
		
			
			|  | 59 | +
 | 
		
	
		
			
			|  | 60 | +	DBGC ( mii, "MII %p restarted autonegotiation\n", mii );
 | 
		
	
		
			
			|  | 61 | +	return 0;
 | 
		
	
		
			
			|  | 62 | +}
 | 
		
	
		
			
			|  | 63 | +
 | 
		
	
		
			
			| 33 | 64 |  /**
 | 
		
	
		
			
			| 34 | 65 |   * Reset MII interface
 | 
		
	
		
			
			| 35 | 66 |   *
 | 
		
	
	
		
			
			|  | @@ -70,11 +101,8 @@ int mii_reset ( struct mii_interface *mii ) {
 | 
		
	
		
			
			| 70 | 101 |  		/* Force autonegotation on again, in case it was
 | 
		
	
		
			
			| 71 | 102 |  		 * cleared by the reset.
 | 
		
	
		
			
			| 72 | 103 |  		 */
 | 
		
	
		
			
			| 73 |  | -		if ( ( rc = mii_write ( mii, MII_BMCR, BMCR_ANENABLE ) ) != 0 ){
 | 
		
	
		
			
			| 74 |  | -			DBGC ( mii, "MII %p could not write BMCR: %s\n",
 | 
		
	
		
			
			| 75 |  | -			       mii, strerror ( rc ) );
 | 
		
	
		
			
			|  | 104 | +		if ( ( rc = mii_restart ( mii ) ) != 0 )
 | 
		
	
		
			
			| 76 | 105 |  			return rc;
 | 
		
	
		
			
			| 77 |  | -		}
 | 
		
	
		
			
			| 78 | 106 |  
 | 
		
	
		
			
			| 79 | 107 |  		DBGC ( mii, "MII %p reset after %dms\n", mii, i );
 | 
		
	
		
			
			| 80 | 108 |  		return 0;
 |