kernels/linux-2.4.0/drivers/net/dmfe.c
/*
   Read a word data from phy register
 */
Read a word data from phy register
Read a word data from phy register
static u16 phy_read(u32 iobase, u8 phy_addr, u8 offset, u32 chip_id)
{
	int i;
	u16 phy_data;
	u32 ioaddr;
	if (chip_id == PCI_DM9132_ID) {
		ioaddr = iobase + 0x80 + offset * 4;
		phy_data = inw(ioaddr);
	} else {
		ioaddr = iobase + DCR9;
		for (i = 0; i < 35; i++)
			phy_write_1bit(ioaddr, PHY_DATA_1);
		phy_write_1bit(ioaddr, PHY_DATA_0);
		phy_write_1bit(ioaddr, PHY_DATA_1);
		phy_write_1bit(ioaddr, PHY_DATA_1);
		phy_write_1bit(ioaddr, PHY_DATA_0);
		for (i = 0x10; i > 0; i = i >> 1)
			phy_write_1bit(ioaddr, phy_addr & i ? PHY_DATA_1 : PHY_DATA_0);
		for (i = 0x10; i > 0; i = i >> 1)
			phy_write_1bit(ioaddr, offset & i ? PHY_DATA_1 : PHY_DATA_0);
		phy_read_1bit(ioaddr);
		for (phy_data = 0, i = 0; i < 16; i++) {
			phy_data <<= 1;
			phy_data |= phy_read_1bit(ioaddr);
		}
	}
	return phy_data;
}
static u16 phy_read ( u32 iobase , u8 phy_addr , u8 offset , u32 chip_id ) { int i ; u16 phy_data ; u32 ioaddr ; if ( chip_id == PCI_DM9132_ID ) { ioaddr = iobase + 0x80 + offset * 4 ; phy_data = inw ( ioaddr ) ; } else { ioaddr = iobase + DCR9 ; for ( i = 0 ; i < 35 ; i ++ ) phy_write_1bit ( ioaddr , PHY_DATA_1 ) ; phy_write_1bit ( ioaddr , PHY_DATA_0 ) ; phy_write_1bit ( ioaddr , PHY_DATA_1 ) ; phy_write_1bit ( ioaddr , PHY_DATA_1 ) ; phy_write_1bit ( ioaddr , PHY_DATA_0 ) ; for ( i = 0x10 ; i > 0 ; i = i >> 1 ) phy_write_1bit ( ioaddr , phy_addr & i ? PHY_DATA_1 : PHY_DATA_0 ) ; for ( i = 0x10 ; i > 0 ; i = i >> 1 ) phy_write_1bit ( ioaddr , offset & i ? PHY_DATA_1 : PHY_DATA_0 ) ; phy_read_1bit ( ioaddr ) ; for ( phy_data = 0 , i = 0 ; i < 16 ; i ++ ) { phy_data <<= 1 ; phy_data |= phy_read_1bit ( ioaddr ) ; } } return phy_data ; }
Read a word data from phy register
Read a word data from phy register
/* DM9132 Chip */ /* DM9102/DM9102A Chip */ /* Send 33 synchronization clock to Phy controller */ /* Send start command(01) to Phy */ /* Send read command(10) to Phy */ /* Send Phy addres */ /* Send register addres */ /* Skip transition state */ /* read 16bit data */