Commit Graph

124 Commits

Author SHA1 Message Date
Wojciech A. Koszek
172ab3e96e Remove unused variable.
Found with:	Coverity Prevent(tm)
CID:		4138
2009-02-06 00:55:19 +00:00
John Baldwin
ba8d936dd2 Goof, catch up to constant rename (I renamed it to match the overall PCI
style of having register offsets start with PCIR_* rather than PCI_*).

Submitted by:	rss
2009-02-02 22:06:20 +00:00
Warner Losh
a84736bdf6 When no driver attaches to a card, don't power down the card. We can
now read config registers of cardbus cards that are inserted, but
aren't attached to a driver.
Also, add a power related comment...
2008-12-31 07:41:42 +00:00
Warner Losh
7d0fb1f7ef Don't call destroy_dev on the alias. This fixes half a dozen PRs I think. 2008-12-02 04:54:31 +00:00
Warner Losh
db8deb424e Create a /dev/cardbus%d.cis, to be compatible with older versions of
the software.  This is a trivial amount of code to keep wireless
monitoring software working...  I plan on removing it in 9.0.
2008-11-21 03:03:57 +00:00
Warner Losh
a7de0b74a7 Overhaul of CIS parsing, next step: keep a cached copy of the CIS,
read before we configure the card, so we can implement
/dev/cardbus*.cis.  Also, do this on a per-child basis, so we now have
a different name than before.  I think i'll have to fix that for some
legacy tools to keep working.

I can now do a dumpcis on my running atheros card and have it still work!
2008-11-17 01:32:29 +00:00
Warner Losh
e371fa4547 First step in cleaning up CIS parsing and /dev/cardbus*.cis: remove
redundant malloc/free.  Add comments about how this should really be
done.  Fix an overly verbose comment about under 1MB mapping: go ahead
and set the bits, but we ignore them.
2008-11-15 05:22:06 +00:00
Warner Losh
714cb2219c Turns out this isn't even used at all... The bogon that I was tracing was
in code from my p4 tree, not -current.  Delete it here.
2008-11-03 06:37:59 +00:00
Warner Losh
89558ee870 Use child (the card) in preference to cbdev (the bridge) when
allocating resources to read the CIS.  I'm not sure when this changed,
but it is totally wrong.  Also, add a minor improvement to the
debugging.

This should help everybody trying to run dumpcis on atheros wireless
card as well.

MFC after:	2 days
2008-11-03 06:06:22 +00:00
Warner Losh
6e39a203de We can't mask out the higher order bits and have the size come out
right...  Good thing the size was ignored...

Where this macro is used, there's no reason to do it anyway.  There
seems to have been some old-time confusion between the CIS pointer
definition, and the BAR definitions at the base of this bug.
2008-11-03 05:52:43 +00:00
Marius Strobl
55aaf894e8 Make the PCI code aware of PCI domains (aka PCI segments) so we can
support machines having multiple independently numbered PCI domains
and don't support reenumeration without ambiguity amongst the
devices as seen by the OS and represented by PCI location strings.
This includes introducing a function pci_find_dbsf(9) which works
like pci_find_bsf(9) but additionally takes a domain number argument
and limiting pci_find_bsf(9) to only search devices in domain 0 (the
only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are
changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order
to no longer report false positives when searching for siblings and
dupe devices in the same domain respectively.
Along with this change the sole host-PCI bridge driver converted to
actually make use of PCI domain support is uninorth(4), the others
continue to use domain 0 only for now and need to be converted as
appropriate later on.
Note that this means that the format of the location strings as used
by pciconf(8) has been changed and that consumers of <sys/pciio.h>
potentially need to be recompiled.

Suggested by:	jhb
Reviewed by:	grehan, jhb, marcel
Approved by:	re (kensmith), jhb (PCI maintainer hat)
2007-09-30 11:05:18 +00:00
Warner Losh
17ee700be6 gcc 4.2 thinks that tupleid is uninitialized. Or might be used
uninitialized.  It gets passed into other routines that initialize
it...  Cope by initializing.

Submitted by: mjacob
2007-06-08 04:03:57 +00:00
John Baldwin
d193b870a5 Fix interrupt routing for some cards after the previous fix to clear BARs
in cardbus cards: update the saved copy of the PCIR_INTLINE register in
the PCI ivars in addition to the actual register.

Reviewed by:	imp
2007-05-16 23:40:08 +00:00
Warner Losh
cfd1374177 Write 0 to all the bars in cardbus_cardbus_setup_regs. This is needed
because on at least my dc based cards there's garbage in there.  The
recent changes in the resource code appears to have unmasked this
problem...  At least dc now probes/attaches better than it did before.

Also, we no longer need to write to the cfg for the other registers.
2007-05-16 20:00:36 +00:00
Warner Losh
4b3337405d Change PCIM_CIS_ASI_TUPLE to _CONFIG.
Add PCI_MAX_BAR_0
minor style nit.
Add PCIM_CIS_CONFIG_MASK
2007-05-16 18:42:38 +00:00
Warner Losh
7e2ff8bbff Cope gracefully with device_get_children returning an error.
Obtained from: Hans Petter Selasky
P4: http://perforce.freebsd.org/chv.cgi?CH=112957
2007-01-19 08:49:28 +00:00
Warner Losh
1acd1e20a1 Minor cleanup of CIS parsing. 2006-06-12 03:28:42 +00:00
Warner Losh
9dfcc6624c Better error message when the CIS is a non-standards conforming '0'. 2006-06-12 03:20:44 +00:00
Warner Losh
a63eba960f When we can't parse the CIS, note with a warning that the bogus CIS
was ignored, rather than freaking out.  In the past, it wasn't possible
to not parse the CIS, so this changes no behavior.
2006-06-12 03:17:24 +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
Warner Losh
bee89c7386 Use the child to allocate the resource rather than bridge, since we're
allocating a resource that's in the card itself.

Remove more now-redundant resource_list_add, and now-redunant code
that lives in the pci layer.

# This fixes the atheros card that I have which had its CIS in one of
# the BARs.  Don't know yet if this fixes the amd64 issues reported.
2006-01-03 03:36:17 +00:00
Warner Losh
c732cf3b2c Minor style(9) hacking, plus use a macro in place of (struct resource *)~0UL
(what the heck does that mean?).
2006-01-03 03:16:53 +00:00
Tai-hwa Liang
93d9fd1136 Fixing build bustage. 2005-12-31 01:45:40 +00:00
Warner Losh
388395ccaa Remove now-obsolete printf warning. 2005-12-30 19:38:47 +00:00
Warner Losh
ef5cc9accd Move all of the resource allocation into the pci layer. The resource
allocation here just duplicated it (badly).
2005-12-30 19:25:04 +00:00
Warner Losh
f3d3468db3 The RID2BAR macro returns a number, not a bitmask. Fix this.
Spotted by: ru, jhb
2005-12-30 19:23:32 +00:00
Gleb Smirnoff
6afb2250fb - Retire BARBIT in favor of new PCI_RID2BAR.
- Fix build.
2005-12-30 11:31:47 +00:00
Warner Losh
3cd242d123 Retire BARBIT in favor of new PCI_RID2BAR. 2005-12-29 23:41:29 +00:00
Gleb Smirnoff
408b85a1e2 Help Warner with merge from p4. 2005-12-29 10:38:42 +00:00
Warner Losh
47147ce799 Implement /dev/cardbus%d.cis, same thing as /dev/pccard%d.cis. There
are some rough edges with this still, but it seems to work well enough
to commit.
2005-12-29 01:43:47 +00:00
Gleb Smirnoff
086745614c When in rev. 1.47 cardbus_alloc_resources() function was moved from
cardbus_cis.c to this file, some code was not merged and thus resource
list entries were invalid. They didn't have a resources attached to
them.
  However, the problem was masked for some time later, because newer
resources list entries were added to the head of the list, and
resource_list_find() always returned the first matching resource list
entry. Usually the underlying driver allocated a valid resource and
added it to the head of the list, and invalid one wasn't used.
  In rev. 1.174 of subr_bus.c the sorting of resource list entries was
reversed demasking the problem in cardbus_alloc_resources().
  This commit fixes the problem returning back some code from
cardbus_cis.c, pre-1.49 revisions.

PR:			kern/87114
PR:			kern/90441
Hardware provided by:	Vasily Olekhov <olekhov yandex.ru>
Reviewed by:		imp
2005-12-28 10:15:01 +00:00
Warner Losh
6811d2bc72 Cardbus has only 1 slot, so simplify a little. 2005-10-28 06:03:53 +00:00
Warner Losh
41ac33a2b6 Eliminate even more duplication, and move some definitions into pcireg.h 2005-10-28 05:55:52 +00:00
Warner Losh
972072d384 Remove now redundant defines. 2005-10-28 05:31:11 +00:00
Warner Losh
495036f25b Simplify code a little, prefer PCI?_FOO registers where possible. 2005-10-28 05:30:47 +00:00
Warner Losh
abca52f4ac Use PCIR_BARS rather than CARDBUS_BASE0_REG
Style nit.
2005-10-28 05:29:41 +00:00
Ruslan Ermilov
360d00a0b2 Calling rman_get_start() after bus_release_resource() is evil.
It became fatal after a recent "struct resource" split change.
2005-09-27 13:33:46 +00:00
Warner Losh
36fed96550 Use STAILQ in preference to SLIST for the resources. Insert new resources
last in the list rather than first.

This makes the resouces print in the 4.x order rather than the 5.x order
(eg fdc0 at 0x3f0-0x3f5,0x3f7 is 4.x, but 0x3f7,0x3f0-0x3f5 is 5.x).  This
also means that the pci code will once again print the resources in BAR
ascending order.
2005-03-18 05:19:50 +00:00
Warner Losh
2219bbc553 Doh! silly typo precludes compiling 2005-03-11 05:30:59 +00:00
Warner Losh
0f675788ff Revert changes of 1.49. Lots-a-people broke with it, for reasons
unknown (since my sony vaio didn't :-(.

Instead, fix the problem described by 1.49 in a different way: just
add the two calls I'd hoped I'd avoid in 1.49 by doing the (wrong)
gymnastics there.  While 1.49 is a good direction to go in, each step
of the way should work :-(.
2005-03-11 05:27:05 +00:00
Warner Losh
af5e97c122 There were two calls to cardbus_do_cis when cardbus_do_cis changed,
yet I only changed one of them.  So when we loaded drivers, we'd fail
to allocate resources correct.

This pointed out that we were doing the wrong thing when we failed to
attach a child.  We released all the resources and almost deleted the
child.  Instead, we should keep the resources allocated so when/if a
driver is loaded, we can go w/o having to allocate them.  We use
pci_cfg_save/restore to restore the BARs with these resources.

This seems to fix the problems that we were seeing that I thought
might have magically gone away in the last revision of cardbus.c (but
really didn't).

Noticed by: avatar (nicely done!)
2005-02-28 01:27:24 +00:00
Warner Losh
509cfe6fb0 Be more verbose on errors with CIS reading. This should be a noop, but
appears to fix the ath problem that had been reported.  I don't see how
it can, so there's likely some other hidden bug.
2005-02-20 20:36:16 +00:00
Warner Losh
164b196506 style(9) nit 2005-02-20 20:32:44 +00:00
Warner Losh
440b5ade31 Move resource allocation routines from cardbus_cis.c to cardbus.c.
They have nothing at all to do with CIS parsing.

Remove some unused funce parsing: nothing used the results.

Use more of pccard_cis.h's deifnitions for the cardbus specific cis
parsing we do.  More work is needed in this area.

This reduces the size of the cardbus module by 380 bytes or so...
2005-02-06 21:03:13 +00:00
Warner Losh
2dd5c91ebb Use the standard FreeBSD license
Approved by: imp, jon
2005-01-13 19:12:10 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Warner Losh
5d11e83faa MFp4:
The hack for setting the bus has been moved down into the cbb driver.
I've been running without this hack in my tree for so long I had
forgotten that I'd removed it :-).  Please let me know if this causes
difficulty for your laptop.
2004-06-27 13:07:02 +00:00
Poul-Henning Kamp
41ee9f1c69 Add some missing <sys/module.h> includes which are masked by the
one on death-row in <sys/kernel.h>
2004-05-30 17:57:46 +00:00
Warner Losh
a7c43559c1 Add note about why we're ignoring the below 1MB bit. 2004-04-11 19:22:25 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00