src/dpdk/drivers/net/e1000/base/e1000_ich8lan.c
s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
{
	s32 ret_val;
	u32 ctrl_reg = 0;
	u32 ctrl_ext = 0;
	u32 reg = 0;
	u16 kmrn_reg = 0;

	DEBUGFUNC("e1000_configure_k1_ich8lan");

	ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
					     &kmrn_reg);
	if (ret_val)
		return ret_val;

	if (k1_enable)
		kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
	else
		kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;

	ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
					      kmrn_reg);
	if (ret_val)
		return ret_val;

	usec_delay(20);
	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
	ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);

	reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
	reg |= E1000_CTRL_FRCSPD;
	E1000_WRITE_REG(hw, E1000_CTRL, reg);

	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
	E1000_WRITE_FLUSH(hw);
	usec_delay(20);
	E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
	E1000_WRITE_FLUSH(hw);
	usec_delay(20);

	return E1000_SUCCESS;
}
/**
 *  e1000_configure_k1_ich8lan - Configure K1 power state
 *  @hw: pointer to the HW structure
 *  @k1_enable: K1 state to configure
 *
 *  Configure the K1 power state based on the provided parameter.
 *  Assumes semaphore already acquired.
 *
 *  Success returns 0, Failure returns -E1000_ERR_PHY (-2)
 **/
Configure K1 power state
@hw: pointer to the HW structure
@k1_enable: K1 state to configure

Configure the K1 power state based on the provided parameter.
Assumes semaphore already acquired.

Success returns 0, Failure returns -E1000_ERR_PHY (-2)
Configure K1 power state @hw : pointer to the HW structure @k1_enable : K1 state to configure Configure the K1 power state based on the provided parameter . Assumes semaphore already acquired . Success returns 0 Failure returns - E1000_ERR_PHY ( - 2 )
s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
{
	s32 ret_val;
	u32 ctrl_reg = 0;
	u32 ctrl_ext = 0;
	u32 reg = 0;
	u16 kmrn_reg = 0;
	DEBUGFUNC("e1000_configure_k1_ich8lan");
	ret_val = e1000_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
					     &kmrn_reg);
	if (ret_val)
		return ret_val;
	if (k1_enable)
		kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
	else
		kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
	ret_val = e1000_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG,
					      kmrn_reg);
	if (ret_val)
		return ret_val;
	usec_delay(20);
	ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
	ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
	reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
	reg |= E1000_CTRL_FRCSPD;
	E1000_WRITE_REG(hw, E1000_CTRL, reg);
	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
	E1000_WRITE_FLUSH(hw);
	usec_delay(20);
	E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
	E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
	E1000_WRITE_FLUSH(hw);
	usec_delay(20);
	return E1000_SUCCESS;
}
s32 e1000_configure_k1_ich8lan ( struct e1000_hw * hw , bool k1_enable ) { s32 ret_val ; u32 ctrl_reg = 0 ; u32 ctrl_ext = 0 ; u32 reg = 0 ; u16 kmrn_reg = 0 ; DEBUGFUNC ( " " ) ; ret_val = e1000_read_kmrn_reg_locked ( hw , E1000_KMRNCTRLSTA_K1_CONFIG , & kmrn_reg ) ; if ( ret_val ) return ret_val ; if ( k1_enable ) kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE ; else kmrn_reg &= ~ E1000_KMRNCTRLSTA_K1_ENABLE ; ret_val = e1000_write_kmrn_reg_locked ( hw , E1000_KMRNCTRLSTA_K1_CONFIG , kmrn_reg ) ; if ( ret_val ) return ret_val ; usec_delay ( 20 ) ; ctrl_ext = E1000_READ_REG ( hw , E1000_CTRL_EXT ) ; ctrl_reg = E1000_READ_REG ( hw , E1000_CTRL ) ; reg = ctrl_reg & ~ ( E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100 ) ; reg |= E1000_CTRL_FRCSPD ; E1000_WRITE_REG ( hw , E1000_CTRL , reg ) ; E1000_WRITE_REG ( hw , E1000_CTRL_EXT , ctrl_ext | E1000_CTRL_EXT_SPD_BYPS ) ; E1000_WRITE_FLUSH ( hw ) ; usec_delay ( 20 ) ; E1000_WRITE_REG ( hw , E1000_CTRL , ctrl_reg ) ; E1000_WRITE_REG ( hw , E1000_CTRL_EXT , ctrl_ext ) ; E1000_WRITE_FLUSH ( hw ) ; usec_delay ( 20 ) ; return E1000_SUCCESS ; }
e1000_configure_k1_ich8lan - Configure K1 power state
  @hw: pointer to the HW structure
  @k1_enable: K1 state to configure
e1000_configure_k1_ich8lan - Configure K1 power state @hw : pointer to the HW structure @k1_enable : K1 state to configure