#include "e1000_osdep.h"
#include "e1000_api.h"
void
e1000_pci_set_mwi(struct e1000_hw *hw)
{
uint16_t val = hw->bus.pci_cmd_word | CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &val);
}
void
e1000_pci_clear_mwi(struct e1000_hw *hw)
{
uint16_t val = hw->bus.pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &val);
}
void
e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
pci_config_put16(OS_DEP(hw)->cfg_handle, reg, *value);
}
void
e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
*value =
pci_config_get16(OS_DEP(hw)->cfg_handle, reg);
}
void
phy_spd_state(struct e1000_hw *hw, boolean_t enable)
{
int32_t offset;
uint16_t spd_bit;
uint16_t reg;
switch (hw->mac.type) {
case e1000_82541:
case e1000_82547:
case e1000_82541_rev_2:
case e1000_82547_rev_2:
offset = IGP01E1000_GMII_FIFO;
spd_bit = IGP01E1000_GMII_SPD;
break;
case e1000_82571:
case e1000_82572:
case e1000_82573:
case e1000_82574:
case e1000_82583:
offset = IGP02E1000_PHY_POWER_MGMT;
spd_bit = IGP02E1000_PM_SPD;
break;
default:
return;
}
(void) e1000_read_phy_reg(hw, offset, ®);
if (enable)
reg |= spd_bit;
else
reg &= ~spd_bit;
(void) e1000_write_phy_reg(hw, offset, reg);
}
int32_t
e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
*value = pci_config_get16(OS_DEP(hw)->cfg_handle,
PCI_EX_CONF_CAP + reg);
return (0);
}
int32_t
e1000_write_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
uint8_t pcie_id = PCI_CAP_ID_PCI_E;
uint16_t pcie_cap;
int32_t status;
status = pci_lcap_locate(OS_DEP(hw)->cfg_handle, pcie_id, &pcie_cap);
if (status == DDI_SUCCESS) {
pci_config_put16(OS_DEP(hw)->cfg_handle,
(off_t)(pcie_cap + reg), *value);
}
return (status);
}
void
e1000_rar_clear(struct e1000_hw *hw, uint32_t index)
{
uint32_t rar_high;
rar_high = ~E1000_RAH_AV;
E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
E1000_WRITE_FLUSH(hw);
}
void
e1000_destroy_hw_mutex(struct e1000_hw *hw)
{
struct e1000_dev_spec_ich8lan *dev_spec;
switch (hw->mac.type) {
case e1000_ich8lan:
case e1000_ich9lan:
case e1000_ich10lan:
case e1000_pchlan:
dev_spec = &hw->dev_spec.ich8lan;
E1000_MUTEX_DESTROY(&dev_spec->nvm_mutex);
E1000_MUTEX_DESTROY(&dev_spec->swflag_mutex);
break;
default:
break;
}
}