FreeBSD/sys/dev/stge/if_stge.c
/*
 * stge_reset:
 *
 *	Perform a soft reset on the TC9021.
 */
Perform a soft reset on the TC9021.
Perform a soft reset on the TC9021 .
static void
stge_reset(struct stge_softc *sc, uint32_t how)
{
	uint32_t ac;
	uint8_t v;
	int i, dv;
	STGE_LOCK_ASSERT(sc);
	dv = 5000;
	ac = CSR_READ_4(sc, STGE_AsicCtrl);
	switch (how) {
	case STGE_RESET_TX:
		ac |= AC_TxReset | AC_FIFO;
		dv = 100;
		break;
	case STGE_RESET_RX:
		ac |= AC_RxReset | AC_FIFO;
		dv = 100;
		break;
	case STGE_RESET_FULL:
	default:
		ac |= AC_GlobalReset | AC_RxReset | AC_TxReset |
		    AC_DMA | AC_FIFO | AC_Network | AC_Host | AC_AutoInit |
		    (sc->sc_usefiber ? AC_RstOut : 0);
		break;
	}
	CSR_WRITE_4(sc, STGE_AsicCtrl, ac);
	DELAY(dv);
	for (i = 0; i < STGE_TIMEOUT; i++) {
		if ((CSR_READ_4(sc, STGE_AsicCtrl) & AC_ResetBusy) == 0)
			break;
		DELAY(dv);
	}
	if (i == STGE_TIMEOUT)
		device_printf(sc->sc_dev, "reset failed to complete\n");
	ac = CSR_READ_4(sc, STGE_AsicCtrl);
	ac &= ~(AC_LEDMode | AC_LEDSpeed | AC_LEDModeBit1);
	if ((sc->sc_led & 0x01) != 0)
		ac |= AC_LEDMode;
	if ((sc->sc_led & 0x03) != 0)
		ac |= AC_LEDModeBit1;
	if ((sc->sc_led & 0x08) != 0)
		ac |= AC_LEDSpeed;
	CSR_WRITE_4(sc, STGE_AsicCtrl, ac);
	v = CSR_READ_1(sc, STGE_PhySet);
	v &= ~(PS_MemLenb9b | PS_MemLen | PS_NonCompdet);
	v |= ((sc->sc_led & 0x70) >> 4);
	CSR_WRITE_1(sc, STGE_PhySet, v);
}
static void stge_reset ( struct stge_softc * sc , uint32_t how ) { uint32_t ac ; uint8_t v ; int i , dv ; STGE_LOCK_ASSERT ( sc ) ; dv = 5000 ; ac = CSR_READ_4 ( sc , STGE_AsicCtrl ) ; switch ( how ) { case STGE_RESET_TX : ac |= AC_TxReset | AC_FIFO ; dv = 100 ; break ; case STGE_RESET_RX : ac |= AC_RxReset | AC_FIFO ; dv = 100 ; break ; case STGE_RESET_FULL : default : ac |= AC_GlobalReset | AC_RxReset | AC_TxReset | AC_DMA | AC_FIFO | AC_Network | AC_Host | AC_AutoInit | ( sc -> sc_usefiber ? AC_RstOut : 0 ) ; break ; } CSR_WRITE_4 ( sc , STGE_AsicCtrl , ac ) ; DELAY ( dv ) ; for ( i = 0 ; i < STGE_TIMEOUT ; i ++ ) { if ( ( CSR_READ_4 ( sc , STGE_AsicCtrl ) & AC_ResetBusy ) == 0 ) break ; DELAY ( dv ) ; } if ( i == STGE_TIMEOUT ) device_printf ( sc -> sc_dev , " \n " ) ; ac = CSR_READ_4 ( sc , STGE_AsicCtrl ) ; ac &= ~ ( AC_LEDMode | AC_LEDSpeed | AC_LEDModeBit1 ) ; if ( ( sc -> sc_led & 0x01 ) != 0 ) ac |= AC_LEDMode ; if ( ( sc -> sc_led & 0x03 ) != 0 ) ac |= AC_LEDModeBit1 ; if ( ( sc -> sc_led & 0x08 ) != 0 ) ac |= AC_LEDSpeed ; CSR_WRITE_4 ( sc , STGE_AsicCtrl , ac ) ; v = CSR_READ_1 ( sc , STGE_PhySet ) ; v &= ~ ( PS_MemLenb9b | PS_MemLen | PS_NonCompdet ) ; v |= ( ( sc -> sc_led & 0x70 ) >> 4 ) ; CSR_WRITE_1 ( sc , STGE_PhySet , v ) ; }
stge_reset:
      Perform a soft reset on the TC9021.
stge_reset : Perform a soft reset on the TC9021 .
/*
		 * Only assert RstOut if we're fiber.  We need GMII clocks
		 * to be present in order for the reset to complete on fiber
		 * cards.
		 */ /* Account for reset problem at 10Mbps. */ /* Set LED, from Linux IPG driver. */ /* Set PHY, from Linux IPG driver */