10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1624Spjha * Common Development and Distribution License (the "License"). 6*1624Spjha * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1624Spjha * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/kmem.h> 300Sstevel@tonic-gate #include <sys/async.h> 310Sstevel@tonic-gate #include <sys/sysmacros.h> 320Sstevel@tonic-gate #include <sys/sunddi.h> 330Sstevel@tonic-gate #include <sys/sunndi.h> 340Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 350Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 360Sstevel@tonic-gate #include <sys/pci/pci_obj.h> 370Sstevel@tonic-gate #include <sys/pci.h> 38*1624Spjha #include <sys/pci_cap.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate /*LINTLIBRARY*/ 410Sstevel@tonic-gate 420Sstevel@tonic-gate void 430Sstevel@tonic-gate pcix_set_cmd_reg(dev_info_t *child, uint16_t value) 440Sstevel@tonic-gate { 45*1624Spjha uint16_t pcix_cap_ptr, pcix_cmd; 460Sstevel@tonic-gate ddi_acc_handle_t handle; 470Sstevel@tonic-gate 480Sstevel@tonic-gate if (pci_config_setup(child, &handle) != DDI_SUCCESS) 490Sstevel@tonic-gate return; 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * Only modify the Command Register of non-bridge functions. 530Sstevel@tonic-gate */ 54*1624Spjha if ((pci_config_get8(handle, PCI_CONF_HEADER) & PCI_HEADER_TYPE_M) 55*1624Spjha == PCI_HEADER_PPB) 56*1624Spjha goto teardown; 570Sstevel@tonic-gate 58*1624Spjha if (PCI_CAP_LOCATE(handle, PCI_CAP_ID_PCIX, &pcix_cap_ptr) == 59*1624Spjha DDI_FAILURE) 60*1624Spjha goto teardown; 610Sstevel@tonic-gate 62*1624Spjha DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: pcix_cap_ptr = %x\n", 63*1624Spjha pcix_cap_ptr); 640Sstevel@tonic-gate 65*1624Spjha /* 66*1624Spjha * Read the PCI-X Command Register. 67*1624Spjha */ 68*1624Spjha if ((pcix_cmd = PCI_CAP_GET16(handle, NULL, pcix_cap_ptr, 2)) 69*1624Spjha == DDI_FAILURE) 70*1624Spjha goto teardown; 710Sstevel@tonic-gate 72*1624Spjha DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: PCI-X CMD Register " 73*1624Spjha "(Before) %x\n", pcix_cmd); 740Sstevel@tonic-gate 75*1624Spjha pcix_cmd &= ~(0x1f << 2); /* clear bits 6-2 */ 76*1624Spjha pcix_cmd |= value; 770Sstevel@tonic-gate 78*1624Spjha DEBUG1(DBG_INIT_CLD, child, "pcix_set_cmd_reg: PCI-X CMD Register " 79*1624Spjha "(After) %x\n", pcix_cmd); 800Sstevel@tonic-gate 81*1624Spjha PCI_CAP_PUT16(handle, NULL, pcix_cap_ptr, 2, pcix_cmd); 820Sstevel@tonic-gate 83*1624Spjha teardown: 840Sstevel@tonic-gate pci_config_teardown(&handle); 850Sstevel@tonic-gate } 86