kernels/linux-2.4.0/drivers/net/dmfe.c
/*
   Write a word to Phy register
 */
Write a word to Phy register
Write a word to Phy register
static void phy_write(u32 iobase, u8 phy_addr, u8 offset, u16 phy_data, u32 chip_id)
{
	u16 i;
	u32 ioaddr;
	if (chip_id == PCI_DM9132_ID) {
		ioaddr = iobase + 0x80 + offset * 4;
		outw(phy_data, 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_0);
		phy_write_1bit(ioaddr, PHY_DATA_1);
		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_write_1bit(ioaddr, PHY_DATA_1);
		phy_write_1bit(ioaddr, PHY_DATA_0);
		for (i = 0x8000; i > 0; i >>= 1)
			phy_write_1bit(ioaddr, phy_data & i ? PHY_DATA_1 : PHY_DATA_0);
	}
}
static void phy_write ( u32 iobase , u8 phy_addr , u8 offset , u16 phy_data , u32 chip_id ) { u16 i ; u32 ioaddr ; if ( chip_id == PCI_DM9132_ID ) { ioaddr = iobase + 0x80 + offset * 4 ; outw ( phy_data , 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_0 ) ; phy_write_1bit ( ioaddr , PHY_DATA_1 ) ; 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_write_1bit ( ioaddr , PHY_DATA_1 ) ; phy_write_1bit ( ioaddr , PHY_DATA_0 ) ; for ( i = 0x8000 ; i > 0 ; i >>= 1 ) phy_write_1bit ( ioaddr , phy_data & i ? PHY_DATA_1 : PHY_DATA_0 ) ; } }
Write a word to Phy register
Write a word to Phy register
/* DM9102/DM9102A Chip */ /* Send 33 synchronization clock to Phy controller */ /* Send start command(01) to Phy */ /* Send write command(01) to Phy */ /* Send Phy addres */ /* Send register addres */ /* written trasnition */ /* Write a word data to PHY controller */