kernels/linux-2.4.0/drivers/net/pcmcia/xircom_tulip_cb.c
/* Provide ioctl() calls to examine the MII xcvr state. */
Provide ioctl() calls to examine the MII xcvr state.
Provide ioctl () calls to examine the MII xcvr state .
static int private_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
	struct tulip_private *tp = (struct tulip_private *)dev->priv;
	long ioaddr = dev->base_addr;
	u16 *data = (u16 *)&rq->ifr_data;
	int phy = tp->phys[0] & 0x1f;
	long flags;
	switch(cmd) {
	case SIOCDEVPRIVATE:		
		if (tp->mii_cnt)
			data[0] = phy;
		else if (tp->chip_id == DC21142)	
			data[0] = 32;
		else if (tp->chip_id == PNIC2)
			data[0] = 32;
		else if (tp->chip_id == COMET)
			data[0] = 1;
		else
			return -ENODEV;
		return 0;
	case SIOCDEVPRIVATE+1:		
		if (data[0] == 32  &&
			(tp->chip_id == DC21142 || tp->chip_id == PNIC2)) {
			int csr12 = inl(ioaddr + CSR12);
			int csr14 = inl(ioaddr + CSR14);
			switch (data[1]) {
			case 0: {
				data[3] = (csr14<<5) & 0x1000;
				break; }
			case 1:
				data[3] = 0x7848 + ((csr12&0x7000) == 0x5000 ? 0x20 : 0)
					+ (csr12&0x06 ? 0x04 : 0);
				break;
			case 4: {
				data[3] = ((csr14>>9)&0x0380) +
					((inl(ioaddr + CSR6)>>3)&0x0040) +((csr14>>1)&0x20) + 1;
				break;
			}
			case 5: data[3] = csr12 >> 16; break;
			default: data[3] = 0; break;
			}
		} else {
			save_flags(flags);
			cli();
			data[3] = mdio_read(dev, data[0] & 0x1f, data[1] & 0x1f);
			restore_flags(flags);
		}
		return 0;
	case SIOCDEVPRIVATE+2:		
#if defined(CAP_NET_ADMIN)
		if (!capable(CAP_NET_ADMIN))
			return -EPERM;
#else
		if (!suser())
			return -EPERM;
#endif
		if (data[0] == 32  &&  tp->chip_id == DC21142) {
			if (data[1] == 5)
				tp->to_advertise = data[2];
		} else {
			save_flags(flags);
			cli();
			mdio_write(dev, data[0] & 0x1f, data[1] & 0x1f, data[2]);
			restore_flags(flags);
		}
		return 0;
	default:
		return -EOPNOTSUPP;
	}
	return -EOPNOTSUPP;
}
static int private_ioctl ( struct net_device * dev , struct ifreq * rq , int cmd ) { struct tulip_private * tp = ( struct tulip_private * ) dev -> priv ; long ioaddr = dev -> base_addr ; u16 * data = ( u16 * ) & rq -> ifr_data ; int phy = tp -> phys [ 0 ] & 0x1f ; long flags ; switch ( cmd ) { case SIOCDEVPRIVATE : if ( tp -> mii_cnt ) data [ 0 ] = phy ; else if ( tp -> chip_id == DC21142 ) data [ 0 ] = 32 ; else if ( tp -> chip_id == PNIC2 ) data [ 0 ] = 32 ; else if ( tp -> chip_id == COMET ) data [ 0 ] = 1 ; else return - ENODEV ; return 0 ; case SIOCDEVPRIVATE + 1 : if ( data [ 0 ] == 32 && ( tp -> chip_id == DC21142 || tp -> chip_id == PNIC2 ) ) { int csr12 = inl ( ioaddr + CSR12 ) ; int csr14 = inl ( ioaddr + CSR14 ) ; switch ( data [ 1 ] ) { case 0 : { data [ 3 ] = ( csr14 << 5 ) & 0x1000 ; break ; } case 1 : data [ 3 ] = 0x7848 + ( ( csr12 & 0x7000 ) == 0x5000 ? 0x20 : 0 ) + ( csr12 & 0x06 ? 0x04 : 0 ) ; break ; case 4 : { data [ 3 ] = ( ( csr14 >> 9 ) & 0x0380 ) + ( ( inl ( ioaddr + CSR6 ) >> 3 ) & 0x0040 ) + ( ( csr14 >> 1 ) & 0x20 ) + 1 ; break ; } case 5 : data [ 3 ] = csr12 >> 16 ; break ; default : data [ 3 ] = 0 ; break ; } } else { save_flags ( flags ) ; cli ( ) ; data [ 3 ] = mdio_read ( dev , data [ 0 ] & 0x1f , data [ 1 ] & 0x1f ) ; restore_flags ( flags ) ; } return 0 ; case SIOCDEVPRIVATE + 2 : #if defined ( CAP_NET_ADMIN ) if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; #else if ( ! suser ( ) ) return - EPERM ; #endif if ( data [ 0 ] == 32 && tp -> chip_id == DC21142 ) { if ( data [ 1 ] == 5 ) tp -> to_advertise = data [ 2 ] ; } else { save_flags ( flags ) ; cli ( ) ; mdio_write ( dev , data [ 0 ] & 0x1f , data [ 1 ] & 0x1f , data [ 2 ] ) ; restore_flags ( flags ) ; } return 0 ; default : return - EOPNOTSUPP ; } return - EOPNOTSUPP ; }
Provide ioctl() calls to examine the MII xcvr state.
Provide ioctl () calls to examine the MII xcvr state .
/* Get the address of the PHY in use. */ /* 21142 pseudo-MII */ /* Read the specified MII register. */ /* Write the specified MII register */