Commit Graph

449 Commits

Author SHA1 Message Date
John Baldwin
cb46523df0 Don't add an agp child in vgapci's attach routine if the PCIY_AGP
capability is present as not all devices supported by the agp_i810 driver
(such as i915) have the AGP capability.  Instead, add an identify routine
to the agp_i810 driver that uses the PCI ID to determine if it should
create an agp child device.
2006-02-01 15:45:29 +00:00
John Baldwin
5aa58b3e8f Make the 'pci_devclass' pointer variable private (drivers really shouldn't
share devclass pointers, a mistake I've encouraged in the past) and
move the declaration of the pci_driver kobj class from cardbus.c to
pci_private.h so that other drivers can inherit from pci_driver.
2006-01-20 22:00:50 +00:00
John Baldwin
04dda605c5 - Make pcib_devclass private to sys/dev/pci/pci_pci.c and change all the
various pcib drivers to use their own private devclass_t variables for
  their modules.
- Use the DEFINE_CLASS_0() macro to declare drivers for the various pcib
  drivers while I'm here.
2006-01-06 19:22:19 +00:00
Warner Losh
a48895a77e Use __HAVE_ACPI and __PCI_REROUTE_INTERRUPT as appropriate rather than
the complicated #ifdefs.
2006-01-01 21:04:31 +00:00
Warner Losh
70261a611f Remove left-over #ifdef alpha routines. They aren't used by any of
our drivers, and don't appear to be necessary for GENERIC and LINT on
the alpha.  They don't belong in a MI header anyway...
2006-01-01 20:40:08 +00:00
Warner Losh
98b7810732 Remove stray debug from p4 integration. 2006-01-01 08:26:39 +00:00
Warner Losh
8d10dd1a82 Make RID2BAR actually return a number that can be plugged into PCIR_BAR()
rather than a bitmask.

Submitted by: ru@
2005-12-30 20:25:40 +00:00
Warner Losh
0c4246bd98 Remove debug now that I've looped back the big changes into my p4 tree. 2005-12-30 19:36:29 +00:00
Warner Losh
a9883bc8c4 Expose pci_add_resources to the outside world, add a 'force' flag to
force allocation of unallocated BARs (cardbus uses this to preallocate
everything).  Add a prefetchmask to allow for busses that get prefetch
hints to set them.  Addjust pci_add_map and pci_ata_maps to take a new
force flag which pci_add_resources will pass in.  Implement 'force' in
pci_add_map.  Write new value of allocated resource into the bar, if
the allocation succeeded (we should have done this before, but with
the new force the bug was very obvious).
2005-12-30 19:28:26 +00:00
Warner Losh
b60c6f4683 Add a macro to map from BAR to rid # (inverse of PCIR_BARS). 2005-12-29 23:40:41 +00:00
John Baldwin
be7ccc4ba3 Return BUS_PROBE_GENERIC rather than 0 in the probe routine.
Requested by:	marius
2005-12-22 16:25:22 +00:00
John Baldwin
8e8e46ccfc Add a vgapci(4) stub device driver for VGA PCI devices. This device serves
as a bus so that other drivers such as drm(4), acpi_video(4), and agp(4)
can attach to it thus allowing multiple drivers for the same device.  It
also removes the need for the drmsub hack for the i8[13]0/i915 drm and agp
drivers.
2005-12-20 22:41:33 +00:00
John Baldwin
5b2119223e Move the hostb driver out of the i386 and amd64 PCI code (where it was
duplicated anyways) and into a single MI driver.  Extend the driver a bit
to implement the bus and PCI kobj interfaces such that other drivers can
attach to it and transparently act as if their parent device is the PCI
bus (for the most part).
2005-12-20 21:09:45 +00:00
John Baldwin
4f9795b9fe Add a new method PCI_FIND_EXTCAP() to the pci bus interface that is used
to search for a specific extended capability.  If the specified capability
is found for the given device, then the function returns success and
optionally returns the offset of that capability.  If the capability is
not found, the function returns an error.
2005-12-20 19:57:47 +00:00
Warner Losh
24ea970aff Improve diagnostic message. 2005-11-09 03:37:52 +00:00
Warner Losh
e5baeed6a6 MFp4: When doing lazy allocation, it turns out that we need to record the
actual resource values we received from the system rather than the range
we requested.  Since we request a range starting at 0, we would record
that number.  Later, since this == 0, we'd allocate again.  However,
we wouldn't write the new resource into the BAR.  This resulted in
a resource leak as well as a BAR that couldn't access the resource at
all since rman_get_start, et al, were wrong.

MFC After: 1 week (assuming RELENG_6 is open for business)
2005-10-29 05:52:17 +00:00
Warner Losh
87623e8dd6 Use symbolic name rather thanhard coding the cap pointer offset for
type two devices.
2005-10-29 05:49:06 +00:00
Warner Losh
00b02fa185 Add PCIM_BIOS_ADDR_MASK too 2005-10-28 06:02:51 +00:00
Warner Losh
0ec342c524 Some cardbus CIS definitions moved here since they are PCI registers. 2005-10-28 05:57:10 +00:00
Warner Losh
46dfab17fb Minor style(9) nitage. 2005-10-28 05:56:50 +00:00
Bill Paul
85155d23de Add a 1 microsecond delay in pci_add_children(), right before the read
of the PCIR_HDRTYPE register. It's the value returned from this
read access that determines whether or not we decide a device is
present at the current slot index. For some reason that I can't
adequately explain, this read fails on my machine when probing the
USB controller on my machine (which happens a multifunction device
at slot index 3 hung off the PCI-PCI bridge on the AMD8111 (bus
index 1)). The read will return 0xFF even though it should return
0x80 to indicate the presence of a multifunction device.

As near as I can tell, there's some timing issue involved with reading
the 'dead' slot indexes 0 through 2 that causes the read of the actual
device at slot 3 to fail. I tried a couple of different tricks to
correct the problem (the patch to amd64/pci/pci_cfgreg.c fixes it
for the amd64 arch), but adding this delay is the only thing that
always allows the USB controllers to be correctly probed 100% of the
time. Whatever the problem is, it's likely confined to the AMD8111
chipset. However, a simple 1us delay is fairly harmless and should
have no side effects for other hardware. I consider this to be
voodoo, but it's fairly benign voodoo and it makes my USB keyboard
and mouse work again.

Note that this is the second time that I've had to resort to a
1us delay to fix a PCI-related problem with this AMD8111/Opteron
system (the first being a fix I made a while back to the NDISulator).
It's possible the delay really belongs in the cfgreg code itself,
or that pci_cfgreg needs some custom hackery for an errata in the
8111. (I checked but couldn't find any documented errata on AMD's
site that could account for these problems.)
2005-10-25 06:53:45 +00:00
John Baldwin
85266973b6 - Consolidate duplicated code for assigning interrupts to PCI devices via
routing, etc. in a static pci_assign_interrupt() function.
- Add a sledgehammer that allows the user to override the interrupt
  assignment of any PCI device via a tunable (e.g. "hw.pci0.7.INTB=5" would
  force any functions on the pci device in slot 7 of bus 0 that use B# to
  use IRQ 5).  This should be used with great caution!  Generally, if the
  interrupt routing in use provides specific tunables (such as hard-wiring
  the IRQ for a given $PIR or ACPI PCI link device), then those should be
  used instead.  One instance where this tunable might be useful is if a
  box has an MPTable with duplicate entries for the same PCI device with
  different IRQs.

MFC after:	1 week
2005-09-29 15:04:41 +00:00
John Baldwin
c306d50969 Don't save and restore the ELCR register across suspend and resume for
the Intel 82371AB PCI-ISA bridge.  We now do this all the time for the
!APIC case in the atpic driver.  This cuts the raw line count for this
driver by about 40%.

MFC after:	1 week
2005-09-29 15:00:09 +00:00
Warner Losh
50757d2fce Split power state control into two variables. hw.pci.do_powerstate
has been removed.  It has been replaced by hw.pci.do_power_nodriver
and hw.pci.do_power_resume.  The former defaults to 0 while the latter
defaults to 1.

When do_powerstate was set to 0, it broke suspend/resume for a lot of
people as an unintended consequence.  This change will only affect the
areas that were intended to affect.  This change will have no effect on
servers, but will help laptops quite a bit.

MFC After: 3 days.
2005-09-21 19:47:00 +00:00
Warner Losh
6c996a0055 Change hw.pci.do_powerstate from a boolean to a range. 0 means the
same as today: do no power management.  1 means be conservative about
what you power down (any device class that has caused problems gets
added here).  2 means be agressive about what gets powered down (any
device class that's fundamental to the system is here).  3 means power
them all down, reguardless.  The default is 1.

The effect in the default system is to add mass storage devices to the
list that we don't power down.  From all the pciconf -l lists that
I've seen for the aac and amr issue, the bad device has been a mass
storage device class.

This is an attempt at a compromise between the very small number of
systems that have extreme issues with powerdown, and the very large
number of systems that gain real benefits from powerdown (I get about
20% more battery life when I attach a minimal set of drivers on my
Sony).  Hopefully it will strike the proper balance.

MFC After: 3 days (before next beta)
2005-09-11 04:09:44 +00:00
Warner Losh
6de560ab92 Allow one to access the cached values for CMDREG, CACHELNSZ, MINGNT,
MAXLAT and LATTIMER.

Improve error message when a bogus RID type is requested for a bar.
2005-09-11 03:22:03 +00:00
Warner Losh
a8cbc96cd8 More consistantly return the correct BAR size. Before, we'd only
return the correct bar size if we encountered a 64-bit BAR that had
its resources already assigned.  If the resources weren't yet
assigned, we'd bogusly assume it was a 32-bit bar and return 1.
2005-09-03 23:15:46 +00:00
John Baldwin
9a1bbc523c Typo in comment. 2005-09-01 16:41:42 +00:00
Warner Losh
b81b5c06b4 Treat resources that are 0xfffff.... as being 'unassigned'.
Reviewed by: jhb
Tested by: Mark Kirkwood
MFC After: 3 days
2005-09-01 02:42:34 +00:00
Jung-uk Kim
c94d6dbee5 fix CardBus issue for Compaq R3000 series laptop
Approved by:	anholt (mentor)
2005-08-26 23:39:44 +00:00
Paul Saab
8910aa92ae For FreeBSD 4 binaries, when trying to read from a device that does
not exsist, do not have ioctl return an error, but instead set -1
in the data returned to the user.  This allows the HP bios flash
utilities to work without requiring changes to their code.

Reviewed by:	jhb
2005-08-26 01:00:19 +00:00
Warner Losh
f8749e3d9b As threatened by BURN_BRIDGES, restire PCIR_MAPS and PCIR_HEADERTYPE 2005-06-05 23:08:59 +00:00
Warner Losh
f9937ed8f3 Mask off the bar's value after the probe test write before testing
against 0 in pci_alloc_map, just like we do in pci_add_map.  Also,
make sure that we restore the value to the BAR that was there before
if the bar is 0.  Chances are that it was 0 before the write too and
that the restoration is a nop, but better safe than sorry.

Notice by: dwhite
2005-06-03 19:41:06 +00:00
John Baldwin
f1e1aa9ba2 Typo.
Submitted by:	njl
2005-06-01 14:07:43 +00:00
John Baldwin
4081108643 Don't enable I/O or memory mode in a device's command register if the BAR
we are processing has a base address of zero.  Note that this will only
change behavior for devices where all the BARs of a given type have a base
address of 0 since we will enable the appropriate access when we encounter
the first BAR with a base that is not 0.  Specifically, this allows certain
Toshiba laptops to no longer require 'hw.pci.enable_io_modes=0' to avoid
hangs during boot.

PR:		kern/20040
PR:		i386/63776 (possibly)
PR:		i386/68900 (possibly)
PR:		i386/74532 (possibly)
MFC after:	1 week
2005-05-31 21:33:33 +00:00
Warner Losh
4e30440d7c Add a detach for pci bridge and pci bus drivers. This allows one to
theoretically unload pci bridges or pci drivers.  It will also allow
detach to work if one needed to detach a subtree.

This is inspired by looking at the p4 commits from bms to his 5.4
tree, but I didn't look at the final results.
2005-04-29 06:22:41 +00:00
Marcel Moolenaar
d98d9b126b In pcib_alloc_resource() check if the resource allocation request is
for the VGA I/O or memory ranges, when it's not within the default
ranges decoded by the bridge. When allocation for VGA addresses is
attempted, check that the bridge has the VGA Enable bit set before
allowing it.
As such, newbusified VGA drivers can allocate their resources when
the VGA adapter is behind a PCI-to-PCI bridge.

Reviewed by: imp@, jhb@
2005-04-29 02:15:40 +00:00
Marcel Moolenaar
9929ff6b5b Add pci_is_vga_ioport_range() and pci_is_vga_memory_range() as inline
functions. These functions centralize the details of which I/O port
and memory ranges belong to VGA.

Reviewed by: imp@, jhb@
2005-04-29 02:03:11 +00:00
Marcel Moolenaar
d1ee178775 Add defines for the Bridge Control Register bits.
Obtained from: jhb@
2005-04-29 01:58:27 +00:00
John Baldwin
9e605855ab Call pci_print_verbose() before pci_add_resources() so that the order of
printf's during a verbose boot is more intuitive (the BAR listings and
interrupt routing info now comes after the config header dump rather than
just before it).
2005-04-14 17:52:55 +00:00
Warner Losh
283f4553ed Fix compile error :-(. 2005-04-13 19:10:27 +00:00
Bruce M Simpson
37ce43b71e Use pci_find_bsf() to retrieve the PCI device associated with
a bus/device/function tuple.
This change enables pciconf(8) to work with CardBus devices.

Reviewed by:	imp
2005-04-13 17:34:38 +00:00
Warner Losh
491bfec707 Default to a interrupt router that returns an invalid interrupt.
Otherwise, busses that implement the pcib interface that forget to
implement pcib_route_interrupt would return EIO, which the caller
interprets as 'use interrupt 6'.  This is likely the cause of much of
the grief that we had when I enabled power modes for the cardbus
bridge, since the card needed to reroute the interrupt to it and it
was getting 6 which was d by the pccbb sanity checks.
2005-04-13 16:30:30 +00:00
Warner Losh
ca44abece9 It isn't a whinable offence to want memory when the bar says ioport.
Put that behind bootverbose to make the ata driver less chatty on
advanced hardware.

Requested by: sos
2005-04-11 02:08:05 +00:00
Warner Losh
69c5c40b2d Go ahead and try to allocate PCI_BAR(5) for ata devices. 2005-04-10 23:49:04 +00:00
John-Mark Gurney
0e49742d03 fix misspelling of 0x30...
Spotted by:	reviewing MFC commit
2005-04-01 22:56:37 +00:00
John-Mark Gurney
5da5a253a5 move the statement about switching power states to just before we do it, so
we don't print a false statement if the destination powerstate is
unsupported...
2005-04-01 16:22:50 +00:00
John-Mark Gurney
1a82818b98 fix a copy/paste typo for scanner/gameport...
Spotted by:	Michal Mertl <mime@traveller.cz>
2005-03-26 22:17:48 +00:00
John-Mark Gurney
4ea3b0e7e2 add some additional pci classes and sub-classes..
Reviewed by:	imp (almost 6 months ago)
2005-03-26 20:31:09 +00:00
John Baldwin
5165a17df5 Add code to read the primary PCI bus number out of the Compaq/HP 6010
hotplug Host to PCI bridge.  This is only needed for the non-ACPI case
as the BIOS includes a proper _BBN method in ACPI.
2005-03-25 14:18:50 +00:00