FreeBSD/sys/dev/nxge/xgehal/xgehal-mgmt.c
/**
 * xge_hal_read_xfp_current_temp -
 * @hldev: HAL device handle.
 *
 * This routine only gets the temperature for XFP modules. Also, updating of the
 * NVRAM can sometimes fail and so the reading we might get may not be uptodate.
 */
xge_hal_read_xfp_current_temp
@hldev: HAL device handle.

This routine only gets the temperature for XFP modules. Also, updating of the
NVRAM can sometimes fail and so the reading we might get may not be uptodate.
xge_hal_read_xfp_current_temp @hldev : HAL device handle . This routine only gets the temperature for XFP modules . Also updating of the NVRAM can sometimes fail and so the reading we might get may not be uptodate .
u32 xge_hal_read_xfp_current_temp(xge_hal_device_h hldev)
{
	u16 val_1, val_2, i = 0;
	u32 actual;
	(void) xge_hal_mdio_write(hldev, XGE_HAL_MDIO_MMD_PMA_DEV_ADDR, 0x8000, 0x3);
	do
	{
	    xge_os_mdelay( 50 ); 
	    val_1 =  xge_hal_mdio_read(hldev, XGE_HAL_MDIO_MMD_PMA_DEV_ADDR, 0x8000);
	    if ( i++ > 10 )
	    {
	        break;
	    }
	}while (( val_1 & 0x000C ) != 0x0004);
	val_1 =  (u8) xge_hal_mdio_read(hldev, XGE_HAL_MDIO_MMD_PMA_DEV_ADDR, 0x8067);
	val_2 =  (u8) xge_hal_mdio_read(hldev, XGE_HAL_MDIO_MMD_PMA_DEV_ADDR, 0x8068);
	actual = ((val_1 << 8) | val_2);
	if (actual >= 32768)
	    actual = actual- 65536;
	actual =  actual/256;
	return actual;
}
u32 xge_hal_read_xfp_current_temp ( xge_hal_device_h hldev ) { u16 val_1 , val_2 , i = 0 ; u32 actual ; ( void ) xge_hal_mdio_write ( hldev , XGE_HAL_MDIO_MMD_PMA_DEV_ADDR , 0x8000 , 0x3 ) ; do { xge_os_mdelay ( 50 ) ; val_1 = xge_hal_mdio_read ( hldev , XGE_HAL_MDIO_MMD_PMA_DEV_ADDR , 0x8000 ) ; if ( i ++ > 10 ) { break ; } } while ( ( val_1 & 0x000C ) != 0x0004 ) ; val_1 = ( u8 ) xge_hal_mdio_read ( hldev , XGE_HAL_MDIO_MMD_PMA_DEV_ADDR , 0x8067 ) ; val_2 = ( u8 ) xge_hal_mdio_read ( hldev , XGE_HAL_MDIO_MMD_PMA_DEV_ADDR , 0x8068 ) ; actual = ( ( val_1 << 8 ) | val_2 ) ; if ( actual >= 32768 ) actual = actual - 65536 ; actual = actual / 256 ; return actual ; }
xge_hal_read_xfp_current_temp
 @hldev: HAL device handle.
xge_hal_read_xfp_current_temp @hldev : HAL device handle .
/* First update the NVRAM table of XFP. */ /* Now wait for the transfer to complete */ // wait 50 milliseonds // waited 500 ms which should be plenty of time. /* Now NVRAM table of XFP should be updated, so read the temp */