FreeBSD/sys/mips/cavium/octe/ethernet-mdio.c
/**
 * Perform an MII read. Called by the generic MII routines
 *
 * @param dev      Device to perform read for
 * @param phy_id   The MII phy id
 * @param location Register location to read
 * @return Result from the read or zero on failure
 */
Perform an MII read. Called by the generic MII routines
@param dev      Device to perform read for
@param phy_id   The MII phy id
@param location Register location to read
@return Result from the read or zero on failure
Perform an MII read . Called by the generic MII routines @param dev Device to perform read for @param phy_id The MII phy id @param location Register location to read @return Result from the read or zero on failure
int cvm_oct_mdio_read(struct ifnet *ifp, int phy_id, int location)
{
	cvmx_smi_cmd_t          smi_cmd;
	cvmx_smi_rd_dat_t       smi_rd;
	MDIO_LOCK();
	smi_cmd.u64 = 0;
	smi_cmd.s.phy_op = 1;
	smi_cmd.s.phy_adr = phy_id;
	smi_cmd.s.reg_adr = location;
	cvmx_write_csr(CVMX_SMI_CMD, smi_cmd.u64);
	do {
		cvmx_wait(1000);
		smi_rd.u64 = cvmx_read_csr(CVMX_SMI_RD_DAT);
	} while (smi_rd.s.pending);
	MDIO_UNLOCK();
	if (smi_rd.s.val)
		return smi_rd.s.dat;
	else
		return 0;
}
int cvm_oct_mdio_read ( struct ifnet * ifp , int phy_id , int location ) { cvmx_smi_cmd_t smi_cmd ; cvmx_smi_rd_dat_t smi_rd ; MDIO_LOCK ( ) ; smi_cmd . u64 = 0 ; smi_cmd . s . phy_op = 1 ; smi_cmd . s . phy_adr = phy_id ; smi_cmd . s . reg_adr = location ; cvmx_write_csr ( CVMX_SMI_CMD , smi_cmd . u64 ) ; do { cvmx_wait ( 1000 ) ; smi_rd . u64 = cvmx_read_csr ( CVMX_SMI_RD_DAT ) ; } while ( smi_rd . s . pending ) ; MDIO_UNLOCK ( ) ; if ( smi_rd . s . val ) return smi_rd . s . dat ; else return 0 ; }
Perform an MII read.
Perform an MII read .