#include <sys/types.h>
#include <sys/kmem.h>
#include <sys/async.h>
#include <sys/sysmacros.h>
#include <sys/sunddi.h>
#include <sys/sunndi.h>
#include <sys/ddi_impldefs.h>
#include <sys/ddi_implfuncs.h>
#include <sys/pci/pci_obj.h>
#include <sys/pci.h>
#include <sys/pci_cap.h>
void
pcix_set_cmd_reg(dev_info_t *child, uint16_t value)
{
uint16_t pcix_cap_ptr, pcix_cmd;
ddi_acc_handle_t handle;
if (pci_config_setup(child, &handle) != DDI_SUCCESS)
return;
if ((pci_config_get8(handle, PCI_CONF_HEADER) & PCI_HEADER_TYPE_M)
== PCI_HEADER_PPB)
goto teardown;
if (PCI_CAP_LOCATE(handle, PCI_CAP_ID_PCIX, &pcix_cap_ptr) ==
DDI_FAILURE)
goto teardown;
DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: pcix_cap_ptr = %x\n",
pcix_cap_ptr);
if ((pcix_cmd = PCI_CAP_GET16(handle, 0, pcix_cap_ptr, 2))
== PCI_CAP_EINVAL16)
goto teardown;
DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: PCI-X CMD Register "
"(Before) %x\n", pcix_cmd);
pcix_cmd &= ~(0x1f << 2);
pcix_cmd |= value;
DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: PCI-X CMD Register "
"(After) %x\n", pcix_cmd);
PCI_CAP_PUT16(handle, 0, pcix_cap_ptr, 2, pcix_cmd);
teardown:
pci_config_teardown(&handle);
}