FreeBSD/sys/dev/utopia/utopia.c
/*
 * This is called by the driver as soon as the SUNI registers are accessible.
 * This may be either in the attach routine or the init routine of the driver.
 */
This is called by the driver as soon as the SUNI registers are accessible.
This may be either in the attach routine or the init routine of the driver.
This is called by the driver as soon as the SUNI registers are accessible . This may be either in the attach routine or the init routine of the driver .
int
utopia_start(struct utopia *utp)
{
	uint8_t reg;
	int err;
	u_int n = 1;
	if ((err = UTP_READREGS(utp, SUNI_REGO_MRESET, &reg, &n)) != 0)
		return (err);
	switch (reg & SUNI_REGM_MRESET_TYPE) {
	  case SUNI_REGM_MRESET_TYPE_622:
		utp->chip = &utopia_chip_622;
		break;
	  case SUNI_REGM_MRESET_TYPE_LITE:
		n = 1;
		if ((err = UTP_READREGS(utp, IDTPHY_REGO_RBER, &reg, &n)) != 0)
			return (err);
		if ((reg & ~IDTPHY_REGM_RBER_RESV) ==
		    (IDTPHY_REGM_RBER_FAIL | IDTPHY_REGM_RBER_WARN))
			utp->chip = &utopia_chip_idt77155;
		else
			utp->chip = &utopia_chip_lite;
		break;
	  case SUNI_REGM_MRESET_TYPE_ULTRA:
		utp->chip = &utopia_chip_ultra;
		break;
	  default:
		if (reg == (IDTPHY_REGM_MCR_DRIC | IDTPHY_REGM_MCR_EI))
			utp->chip = &utopia_chip_idt77105;
		else {
			if_printf(utp->ifatm->ifp,
			    "unknown ATM-PHY chip %#x\n", reg);
			utp->chip = &utopia_chip_unknown;
		}
		break;
	}
	utp->state |= UTP_ST_ACTIVE;
	return (0);
}
int utopia_start ( struct utopia * utp ) { uint8_t reg ; int err ; u_int n = 1 ; if ( ( err = UTP_READREGS ( utp , SUNI_REGO_MRESET , & reg , & n ) ) != 0 ) return ( err ) ; switch ( reg & SUNI_REGM_MRESET_TYPE ) { case SUNI_REGM_MRESET_TYPE_622 : utp -> chip = & utopia_chip_622 ; break ; case SUNI_REGM_MRESET_TYPE_LITE : n = 1 ; if ( ( err = UTP_READREGS ( utp , IDTPHY_REGO_RBER , & reg , & n ) ) != 0 ) return ( err ) ; if ( ( reg & ~ IDTPHY_REGM_RBER_RESV ) == ( IDTPHY_REGM_RBER_FAIL | IDTPHY_REGM_RBER_WARN ) ) utp -> chip = & utopia_chip_idt77155 ; else utp -> chip = & utopia_chip_lite ; break ; case SUNI_REGM_MRESET_TYPE_ULTRA : utp -> chip = & utopia_chip_ultra ; break ; default : if ( reg == ( IDTPHY_REGM_MCR_DRIC | IDTPHY_REGM_MCR_EI ) ) utp -> chip = & utopia_chip_idt77105 ; else { if_printf ( utp -> ifatm -> ifp , " \n " , reg ) ; utp -> chip = & utopia_chip_unknown ; } break ; } utp -> state |= UTP_ST_ACTIVE ; return ( 0 ) ; }
This is called by the driver as soon as the SUNI registers are accessible.
This is called by the driver as soon as the SUNI registers are accessible .
/*
	 * Try to find out what chip we have
	 */ /* this may be either a SUNI LITE or a IDT77155 *
		 * Read register 0x70. The SUNI doesn't have it */