pci.c (197406) | pci.c (198151) |
---|---|
1/*- 2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000, BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org> 3 * Copyright (c) 2000, Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000, BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 197406 2009-09-22 15:43:03Z jhb $"); | 30__FBSDID("$FreeBSD: head/sys/dev/pci/pci.c 198151 2009-10-15 20:07:08Z thompsa $"); |
31 32#include "opt_bus.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> 37#include <sys/module.h> 38#include <sys/linker.h> --- 18 unchanged lines hidden (view full) --- 57#include <machine/intr_machdep.h> 58#endif 59 60#include <sys/pciio.h> 61#include <dev/pci/pcireg.h> 62#include <dev/pci/pcivar.h> 63#include <dev/pci/pci_private.h> 64 | 31 32#include "opt_bus.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> 37#include <sys/module.h> 38#include <sys/linker.h> --- 18 unchanged lines hidden (view full) --- 57#include <machine/intr_machdep.h> 58#endif 59 60#include <sys/pciio.h> 61#include <dev/pci/pcireg.h> 62#include <dev/pci/pcivar.h> 63#include <dev/pci/pci_private.h> 64 |
65#include <dev/usb/controller/ehcireg.h> 66#include <dev/usb/controller/ohcireg.h> 67#include <dev/usb/controller/uhcireg.h> 68 |
|
65#include "pcib_if.h" 66#include "pci_if.h" 67 68#ifdef __HAVE_ACPI 69#include <contrib/dev/acpica/include/acpi.h> 70#include "acpi_if.h" 71#else 72#define ACPI_PWR_FOR_SLEEP(x, y, z) --- 192 unchanged lines hidden (view full) --- 265SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RW, &pci_do_msix, 1, 266 "Enable support for MSI-X interrupts"); 267 268static int pci_honor_msi_blacklist = 1; 269TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist); 270SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD, 271 &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI"); 272 | 69#include "pcib_if.h" 70#include "pci_if.h" 71 72#ifdef __HAVE_ACPI 73#include <contrib/dev/acpica/include/acpi.h> 74#include "acpi_if.h" 75#else 76#define ACPI_PWR_FOR_SLEEP(x, y, z) --- 192 unchanged lines hidden (view full) --- 269SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RW, &pci_do_msix, 1, 270 "Enable support for MSI-X interrupts"); 271 272static int pci_honor_msi_blacklist = 1; 273TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist); 274SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD, 275 &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI"); 276 |
277static int pci_usb_takeover = 1; 278TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover); 279SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RD | CTLFLAG_TUN, 280 &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\ 281Disable this if you depend on BIOS emulation of USB devices, that is\n\ 282you use USB devices (like keyboard or mouse) but do not load USB drivers"); 283 |
|
273/* Find a device_t by bus/slot/function in domain 0 */ 274 275device_t 276pci_find_bsf(uint8_t bus, uint8_t slot, uint8_t func) 277{ 278 279 return (pci_find_dbsf(0, bus, slot, func)); 280} --- 2283 unchanged lines hidden (view full) --- 2564 cfg->intline = irq; 2565 pci_write_config(dev, PCIR_INTLINE, irq, 1); 2566 } 2567 2568 /* Add this IRQ as rid 0 interrupt resource. */ 2569 resource_list_add(&dinfo->resources, SYS_RES_IRQ, 0, irq, irq, 1); 2570} 2571 | 284/* Find a device_t by bus/slot/function in domain 0 */ 285 286device_t 287pci_find_bsf(uint8_t bus, uint8_t slot, uint8_t func) 288{ 289 290 return (pci_find_dbsf(0, bus, slot, func)); 291} --- 2283 unchanged lines hidden (view full) --- 2575 cfg->intline = irq; 2576 pci_write_config(dev, PCIR_INTLINE, irq, 1); 2577 } 2578 2579 /* Add this IRQ as rid 0 interrupt resource. */ 2580 resource_list_add(&dinfo->resources, SYS_RES_IRQ, 0, irq, irq, 1); 2581} 2582 |
2583/* Perform early OHCI takeover from SMM. */ 2584static void 2585ohci_early_takeover(device_t self) 2586{ 2587 struct resource *res; 2588 uint32_t ctl; 2589 int rid; 2590 int i; 2591 2592 rid = PCIR_BAR(0); 2593 res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); 2594 if (res == NULL) 2595 return; 2596 2597 ctl = bus_read_4(res, OHCI_CONTROL); 2598 if (ctl & OHCI_IR) { 2599 if (bootverbose) 2600 printf("ohci early: " 2601 "SMM active, request owner change\n"); 2602 bus_write_4(res, OHCI_COMMAND_STATUS, OHCI_OCR); 2603 for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) { 2604 DELAY(1000); 2605 ctl = bus_read_4(res, OHCI_CONTROL); 2606 } 2607 if (ctl & OHCI_IR) { 2608 if (bootverbose) 2609 printf("ohci early: " 2610 "SMM does not respond, resetting\n"); 2611 bus_write_4(res, OHCI_CONTROL, OHCI_HCFS_RESET); 2612 } 2613 } 2614 2615 bus_release_resource(self, SYS_RES_MEMORY, rid, res); 2616} 2617 2618/* Perform early UHCI takeover from SMM. */ 2619static void 2620uhci_early_takeover(device_t self) 2621{ 2622 /* 2623 * Set the PIRQD enable bit and switch off all the others. We don't 2624 * want legacy support to interfere with us XXX Does this also mean 2625 * that the BIOS won't touch the keyboard anymore if it is connected 2626 * to the ports of the root hub? 2627 */ 2628 pci_write_config(self, PCI_LEGSUP, PCI_LEGSUP_USBPIRQDEN, 2); 2629} 2630 2631/* Perform early EHCI takeover from SMM. */ 2632static void 2633ehci_early_takeover(device_t self) 2634{ 2635 struct resource *res; 2636 uint32_t cparams; 2637 uint32_t eec; 2638 uint8_t eecp; 2639 uint8_t bios_sem; 2640 int rid; 2641 int i; 2642 2643 rid = PCIR_BAR(0); 2644 res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); 2645 if (res == NULL) 2646 return; 2647 2648 cparams = bus_read_4(res, EHCI_HCCPARAMS); 2649 2650 /* Synchronise with the BIOS if it owns the controller. */ 2651 for (eecp = EHCI_HCC_EECP(cparams); eecp != 0; 2652 eecp = EHCI_EECP_NEXT(eec)) { 2653 eec = pci_read_config(self, eecp, 4); 2654 if (EHCI_EECP_ID(eec) != EHCI_EC_LEGSUP) { 2655 continue; 2656 } 2657 bios_sem = pci_read_config(self, eecp + 2658 EHCI_LEGSUP_BIOS_SEM, 1); 2659 if (bios_sem == 0) { 2660 continue; 2661 } 2662 if (bootverbose) 2663 printf("ehci early: " 2664 "SMM active, request owner change\n"); 2665 2666 pci_write_config(self, eecp + EHCI_LEGSUP_OS_SEM, 1, 1); 2667 2668 for (i = 0; (i < 100) && (bios_sem != 0); i++) { 2669 DELAY(1000); 2670 bios_sem = pci_read_config(self, eecp + 2671 EHCI_LEGSUP_BIOS_SEM, 1); 2672 } 2673 2674 if (bios_sem != 0) { 2675 if (bootverbose) 2676 printf("ehci early: " 2677 "SMM does not respond\n"); 2678 } 2679 } 2680 bus_release_resource(self, SYS_RES_MEMORY, rid, res); 2681} 2682 |
|
2572void 2573pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask) 2574{ 2575 struct pci_devinfo *dinfo = device_get_ivars(dev); 2576 pcicfgregs *cfg = &dinfo->cfg; 2577 struct resource_list *rl = &dinfo->resources; 2578 struct pci_quirk *q; 2579 int i; --- 27 unchanged lines hidden (view full) --- 2607 * If the re-route fails, then just stick with what we 2608 * have. 2609 */ 2610 pci_assign_interrupt(bus, dev, 1); 2611#else 2612 pci_assign_interrupt(bus, dev, 0); 2613#endif 2614 } | 2683void 2684pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask) 2685{ 2686 struct pci_devinfo *dinfo = device_get_ivars(dev); 2687 pcicfgregs *cfg = &dinfo->cfg; 2688 struct resource_list *rl = &dinfo->resources; 2689 struct pci_quirk *q; 2690 int i; --- 27 unchanged lines hidden (view full) --- 2718 * If the re-route fails, then just stick with what we 2719 * have. 2720 */ 2721 pci_assign_interrupt(bus, dev, 1); 2722#else 2723 pci_assign_interrupt(bus, dev, 0); 2724#endif 2725 } |
2726 2727 if (pci_usb_takeover && pci_get_class(dev) == PCIC_SERIALBUS && 2728 pci_get_subclass(dev) == PCIS_SERIALBUS_USB) { 2729 if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_EHCI) 2730 ehci_early_takeover(dev); 2731 else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_OHCI) 2732 ohci_early_takeover(dev); 2733 else if (pci_get_progif(dev) == PCIP_SERIALBUS_USB_UHCI) 2734 uhci_early_takeover(dev); 2735 } |
|
2615} 2616 2617void 2618pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size) 2619{ 2620#define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w) 2621 device_t pcib = device_get_parent(dev); 2622 struct pci_devinfo *dinfo; --- 1277 unchanged lines hidden --- | 2736} 2737 2738void 2739pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size) 2740{ 2741#define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w) 2742 device_t pcib = device_get_parent(dev); 2743 struct pci_devinfo *dinfo; --- 1277 unchanged lines hidden --- |