Commit Graph

270 Commits

Author SHA1 Message Date
Warner Losh
2f6303b0f6 Suspend the children before we turn off card events in hardware. This
was done, I believe, to work around some cards having issues in the
suspend case.  I think that this helped my Sony VAIO TS505 work better
when it had certain wireless cards in it and I did a apm -z.  I've not
tested suspend/resume on other laptops in a long time, so I hope this
doesn't cause greif.  Please let me know if it does.
2006-05-24 17:26:16 +00:00
Warner Losh
1b2ec08c94 Fix a race when detaching the cbb worker thread. There were a couple
of cases where we didn't take out the lock before setting or clearing
a bit.  This apparently can lead to a race at kldunload time (at least
on my Turion64 laptop, never saw it on my Sony Vaio).
2006-05-24 17:22:53 +00:00
Warner Losh
2c24bd34d6 Whitespace nits 2006-05-23 23:33:57 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Warner Losh
ebcd52935b Add missing ~. We want all the INVALID bits to be 0... Let's see if this
helps people with their interrupt storm problem on card eject.
2006-04-16 23:16:45 +00:00
Warner Losh
a49ed2a673 On some laptops, under very high loads, the socket event register read
in the ISR doesn't read the actual socket event register, but instead
reads garbage (usually 0xffffffff, but other times other things).
This totally violates the PCI spec, but happens rarely enough that a
workaround is in order.  This adds one test when we have a real
interrupt to service (which is very rare), and doesn't affect the
usualy 'nothing to see here' case at all.

Problem reported by many, but sam@ gave me this workaround after
diagnosing the problem.
2006-03-30 04:25:45 +00:00
Warner Losh
ee516cac43 Add a mask of valid socket events
While I'm hear, fix define<sp> to be define<tab>.
2006-03-30 04:12:28 +00:00
Warner Losh
1ab7d4c93d For each of the voltages that a card might support, make sure that the
socket also supports the voltage.  Some XV cards have appeared on the
scene (or cards that report they support XV), and in older machines
that have sockets that do not support XV, we were bogusly trying to
power them at XV rather than at 3.3V.  Now, power up the card at the
lowest voltage supported by both the card and the socket.

MFC After: 3 days
2006-03-24 07:52:00 +00:00
Warner Losh
22293c3afb Detach the children before we delete them. This is a little cleaner
than just deleting them.  Also add comments about why we do this.
Given the current behavior of delete_child, I don't think this changes
anything.  It just feels cleaner.
2006-02-07 18:38:51 +00:00
Warner Losh
44dc92eb94 Now that TUNABLE_ULONG is in the tree, and has been for a while, use it.
This also avoids typepunning.
2006-02-04 21:56:14 +00:00
Warner Losh
ef8984f5dc Remove extra debugging that crept in with the integration from p4. 2005-12-31 20:04:39 +00:00
Warner Losh
3ac604874c Simplify the opening of the resources for cardbus cards. Before we'd
try very hard to be perfect.  However, these attempts broke down when
there were large numbers of resources.  We'd not be able to map them all.

Instead, accept that we might pass more range to thse subbus than
might be optimal be able to compute.  However, there's little harm in
this and it allows us to pass greater resources through.

# it has been suggested that we allocate a fixed amount of resources
# on attach and give it out upon request.  This might not be a bad idea...
2005-12-29 23:38:45 +00:00
Warner Losh
0e6e3c1384 Ensure that we're aligned at leas tto the size of the resource being requested.
When cbb_debug is on, print the windows that we're mapping.
2005-12-27 19:18:11 +00:00
Warner Losh
0780312f3d nits 2005-12-27 18:55:21 +00:00
Warner Losh
fdb0b1368e Mollify the whitespace police 2005-11-08 15:42:12 +00:00
Warner Losh
ba61c672f6 Shutdown a little better by commenting the shutdown code and acknowledging
any interrupts after we turn off the interrupt mask.
2005-10-29 03:36:00 +00:00
Warner Losh
d9a423c36f Shut down the card bus bridge hardware on detach. Before we'd just
free the resoruces w/o actually turning off the interrupts.  This lead
to interrupt storms if you were to insert a card after kldunloading
the driver.
2005-10-29 03:27:43 +00:00
Warner Losh
d9efa52e17 Make sure we set bst and bsh in the softc.
This gets us probing, but not attaching to, ISA cards.  More work
needed since the ISA attach routine is return ENXIO right now :-)
2005-10-19 00:18:11 +00:00
Warner Losh
2ae7662803 Merge in WIP from p4 for supporting ISA pccard bridges conforming to
the ExCA spec, and close cousins:

o Write an activate routine that works.
o merge a couple of items from oldcard before they are lost
o write a deactivate routine

I suspect we're still a ways away from having this work, but maybe for
6.1/5.5?
2005-10-14 04:47:18 +00:00
Warner Losh
7f33c2df93 MFP4: More removal of unused stuff. 2005-10-08 06:58:51 +00:00
Warner Losh
f481fa4d29 MFP4: Changes to hopefully make the new power code work better
o Rather than just try to turn off EXCA_INTR_RESET, set the entire register
  to 0.  This is slightly faster, and a better hammer.
o Move attempted clearing of the output enable (EXCA_PWRCTL_OE) back to
  after we turn off the power.  Modify it to write 0 so that we don't get
  Bad Vcc messages on TI bridges (untested, but ru@ sent me a similar patch)
  while at the same time avoiding interrupt storms on Ricoh bridges (tested
  by me on my Sony).

# Many of my observations of 'breakage' for this patch are due to some bug
# in the load/unload of cbb.ko unlreated to this change.  I'll be investigating
# and fixing that bug in the fullness of time.
2005-10-08 06:57:13 +00:00
Warner Losh
f1abc0ea53 MFP4: We no longer use intr_handlers, so remove it. 2005-10-08 06:53:17 +00:00
Warner Losh
ed448ee4de MFP4: Note why we do the dance we do for waiting for the thread to die. 2005-10-08 06:51:47 +00:00
Warner Losh
550a624879 Fix bad compile. Pointy hat to: imp 2005-09-29 20:41:04 +00:00
Warner Losh
870d00144f o Add a bunch of o2micro controller IDs
o Add SMC34C90 to list as well, since I've found enough more data about it
  since my original research to know it is appropriate for this driver.
2005-09-29 19:59:03 +00:00
Warner Losh
aafbf20db0 I added the device IDs to the header, but not to the table. Add them
to the table.

MFC After: 3 days
2005-09-29 14:57:51 +00:00
Warner Losh
c82f53f61d 'PC Card' instead of other variants 2005-09-22 06:01:44 +00:00
Warner Losh
5c4f7048b8 This appears to be good for some folks, but really bad for others.
Until we know why, back out 1.127.
2005-09-12 05:35:11 +00:00
Warner Losh
8fe5efa81f Minor improvement for the suspend case for Ricoh based (and others)
CardBus bridges.
2005-09-08 17:18:42 +00:00
Warner Losh
b32757b431 o The ricoh bridge needs us to turn off the function interrupts for
16-bit cards when we're powering them up.  Other bridges may have
  similar issues, so we do this for all of them by setting the
  interrupt in the PCIC register 3 to be 0 (done always anyway)
  and turning on the bit in the bridge control register to route these
  interrupts via the ISA bus (or via the interrupt configured in the
  PCIC register 3).  '0' means disable completely.  There's a small
  chance this may interfere with the o2micro power hacks, but I'll
  wait for reports to come in from o2micro users.
o Expand some of the comments about why we do certain things.

# this gets rid of the interrupt storm warnings on my 505TS.  I think
# that we may need to do something similar on suspend, but I'm unsure
# since I don't have a laptop that supports suspened/resume with a
# ricoh chipset in it.
2005-07-17 19:40:05 +00:00
Warner Losh
f99298f422 Rename a bit to make it clearer that it enables routing of the function
interrupts to the ISA bus.
2005-07-17 19:31:39 +00:00
Warner Losh
85ef2343c4 The CD interrupt should only be enabled after we've initialized the
card.  Mask it while we're doing power things, as the PC Card standard
suggests.  Also, poll the POWER_CYCLE bit 10x a second as well as
providing a timeout for power cycle interrupt to happen.

The Ricoh '475 that I have doesn't seem to generate an interrupt for
power at the present time, so the polling is necessary for reasons as
yet unknown.  This results in an interrupt storm warning that I'm
still trying to quantify (the o2micro trick doesn't work to mitigate
this storm).  At the very least, this should help those users that
lost pccards on boot with the prior rev of this code.  My VAIO
PCG-505TS is now happier, but more investigation is necessary.
2005-07-17 07:48:28 +00:00
Warner Losh
ce71e8d87f s/_us// 2005-07-15 04:11:42 +00:00
Warner Losh
d224ede0da Move to using tsleeps in the cardbus reset case as well. This
eliminates the last of the DELAYs in pccbb.
2005-07-15 03:25:22 +00:00
Warner Losh
fd4e475233 Omnibus power and interrupt fixes:
o Don't busy wait on powerup.  Instead, use the power up interrupt to wait
  for the card to power up.  Don't wait when we're turning the card off,
  since no interrupt happens in that case.
o Convert many of the long DELAYs to tsleeps.  We do not run before
  the timer have stared, so DELAY isn't necessary.  More DELAYs can likely
  be eliminated in the future.
o When powering up the card, don't do anything if the card is already
  powered up (before we'd power cycle it).  This means that for most
  cards we power them up once and then never change the power.
o On card eject, mask (by clearing) the CD bit.  Before we set it, which
  was wrong.  We don't want to see any CD events past the first one since
  they need to be debounced.

With these changes, I can insert/eject 16bit cards without glitching xmms'
sound output.  Something very important to the development of better pccard
drivers :-)
2005-07-14 20:46:59 +00:00
Warner Losh
8e656629c7 Not yet ready to burn this, so unmark power stuff.... non-type 0 busses still need to do this 2005-06-06 06:05:32 +00:00
Warner Losh
3f7d3c1e3c Since cbb implements the pcib_ interface, it must also implement the
pcib_route_interrupt interface.  Since there's only one interrupt pin
in the CardBus form factor, everybody gets to share it.  Implement
cbb_route_interrupt to return the interrupt we have.

Suggested by: bms
2005-04-13 16:35:15 +00:00
Warner Losh
6b9907e7f8 Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 18:10:49 +00:00
Warner Losh
523675f64c Use the standard FreeBSD license for these files.
Approved by: imp, jon
2005-01-13 19:05:25 +00:00
Warner Losh
eb523c72cf The card activation failured message is lame, and not done for other
busses, nor for the 16-bit cards.  Eliminate it.
2005-01-11 05:38:01 +00:00
Warner Losh
afa87f87c8 /* -> /*- for a second clause 2005-01-11 05:34:14 +00:00
Warner Losh
a731bf6779 Use the FreeBSD standard license, since there's no reason to use the
version I have here.
2005-01-11 05:33:18 +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
2969a6a9d6 Add recognition of O2Micro 711M1.
Submitted by: Gordon Bergling
2004-12-23 05:28:36 +00:00
Warner Losh
b67471f34a Don't need to declare cbb module. don't know why I never saw
duplicate messages..
2004-08-16 06:33:58 +00:00
Warner Losh
93185c7468 Move towards isa attachment for pccbb. This is a work in progress, but
works well with the pci attachment.
2004-08-12 06:50:29 +00:00
Warner Losh
d9975d06e1 Add IDs from TI's web site. Reports from the field and inspection of
the data sheets leads me to believe these will just work.  Those parts
with the various media readers on them may not have the required
FreeBSD drivers that will attach to the subdevices that will be seen
on some of these parts.

PCI 1515, 1530, 1620, 4520, 6411, 6420, 7410, 7510, 7610

Prompted by: Havard Eidnes
2004-07-22 20:19:57 +00:00
Warner Losh
e2b194a02d More TI device IDs.
These are from the datasheets downloaded from TI's web site.
They describe the PCI[67]x[12]1 and PCI[67]x20 parts, with and without
the smartcard enabled.
2004-07-22 20:02:16 +00:00
Warner Losh
284b024b2b Update comment about fast interrupts to be closer to reality 2004-07-22 07:44:10 +00:00
Warner Losh
b0ba9e25bc Improve the kludge assignment of sub-bus numbers a little by fixing an
off by one error.  subbus must be > than pribus, so the right test is
<= not just <.

Reported by: Peter Losher
2004-06-23 13:49:46 +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
2a6c850c09 When attaching pccard and cardbus children, there's no need to set the
device == NULL on failure.  A warning should suffice.

# I wrote this back before I understood the unattached but loosely bound
# newbus concept...
2004-05-21 06:11:47 +00:00
Warner Losh
2a829b00f4 Now that we have the resource allocation code in current, the kludge
to try to allocate things on my parent can be taken out.  It duplicates code.

Also, add comment about why the power state stuff is here (type 2
devices don't participate in the power state save/restore due to
larger Bx issues).
2004-05-21 06:10:13 +00:00
Warner Losh
923332f7c5 Need to mark the interrupt from cbb as being MP safe on resume too. 2004-05-04 02:25:00 +00:00
Warner Losh
6c92cac930 Start programming the bus numbers for the pci<->cardbus. When the
secondary bus is 0, we program the primary bus, the secondary bus and
the suborindate bus.  This isn't ideal, since we start at parent_bus +
1 and store this in a static.

Ideally, we'd walk the tree and assign bus numbers.  However, that's
harder to accomplish without some help from the bus layer which we're
not planning on doing that until 6.

This fixes my CardBus problems on my Sony PCG-Z1WA, and might fix the
Dells that have had problems.
2004-04-23 05:25:13 +00:00
Warner Losh
57094462fc Remove extra copy of code.
Noticed by: Carlos Velasco
2004-04-13 14:39:26 +00:00
Warner Losh
9b582996a6 MFp4:
Alignment for pccards should also be treated in a similar way that
	we tread it for cardbus cards.

	Remove bogus debugs while I'm here.

# This is also necessary to make the CIS reading work.

Submitted by: Carlos Velasco
2004-04-12 21:04:54 +00:00
Warner Losh
0a6c6a6dd2 Better checks to make sure that we get good alignment. This code is a
bit of a bandaide until I get better pci bus code committed to head
from my p4 tree.
2004-04-06 22:50:50 +00:00
Warner Losh
70fc36e89c Fix mis-merge from p4 by adding line getting sc.
Attempt to deal with larger memory allocation better.
2004-04-06 22:41:14 +00:00
Warner Losh
1ca203ae4b MFP4: Power up with OE disabled. Similar patches went into NetBSD a
while ago, and it does seem to help at least one card I have and has
been in my p4 tree for many months.
2004-04-06 20:13:29 +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
John Baldwin
6074439965 kthread_exit() no longer requires Giant, so don't force callers to acquire
Giant just to call kthread_exit().

Requested by:	many
2004-03-05 22:42:17 +00:00
Warner Losh
9a6fdece27 MFp4:
o O2Micro OZ711e1 is now recognized (note: I don't have one, and the current
  owner of the Dell laptop is reporting problems).
o minor nits wrt copyright date.
2004-01-04 22:10:00 +00:00
Warner Losh
3c4c657681 Fix typo in ENE CB710 description. It isn't a 720. 2003-12-22 06:09:35 +00:00
Warner Losh
a66f2afd1a Fix a harmless typo (use of res instead of rle: if rle is NULL, we'd
still get a panic, just not a nice message) and update to new
__FBSDID.

Submitted by: charnier@
2003-11-12 05:21:06 +00:00
Warner Losh
d0ff2e64ac -Wunused 2003-11-08 03:28:43 +00:00
Warner Losh
123cd74e26 Remove channeling interrupts to IRQ1. Some chipsets don't do the
expected thing and that causes interference with keyboards.
2003-11-07 23:12:59 +00:00
Warner Losh
d2bda4e032 Backswards is as backwards does: If we're MPSAFE, then we don't need
giant, which implies that we need to take out giant it we're NOT
MPSAFE.

# I can't believe the number of people that looked at this failed to
# detect this.
2003-10-24 07:20:13 +00:00
Warner Losh
572e53c2ac Add newly discovered ENE Technologies CardBus bridges to the list:
CB710, CB720, CB1211, CB1225, CB1410 and CB1420
These are likely licensed designed from TI, and the Linux PCMCIA code
treats them as TI chips.

Add comment, but no ID for the 711E1 from O2Micro.
2003-08-22 08:49:56 +00:00
Warner Losh
38d8c9940b Prefer new location of pci include files (which have only been in the
tree for two or more years now), except in a few places where there's
code to be compatible with older versions of FreeBSD.
2003-08-22 06:42:59 +00:00
Warner Losh
08d63b4c8f In my efforts to make checking the CD bits less error-prone, I
introduced an error.  In power_enable_socket, we only return ENODEV if
there isn't a card, not if there is a card.  Ooops.

Pointy hat to: bsdimp
2003-08-20 23:43:20 +00:00
Maxime Henrion
c8c57208ce Fix typo in last commit. 2003-08-20 11:27:58 +00:00
Warner Losh
74a9cb0969 Use CBB_CARD_PRESENT instead of checking STATE_CD directly since it is
hard to get right.
2003-08-20 06:13:01 +00:00
Warner Losh
f2d72e24b3 The CD bits in the CBB_SOCKET_STATE register are 0 when the card is
present, and non-zero when it is (or may be) absent.  The test
cbb_child_present was backwards.  However, typical usage in the tree
would cause it to do the right thing because the card really wasn't
there the OK flag would be turned on.

Also, assume that if any of these bits are turned on we don't have a
card, rather than requiring both of them in the suspend/resume
routines.

Noticed by: cognet
2003-08-18 21:59:24 +00:00
Warner Losh
da245931e3 Put the clearing of the socket cd interrupt and setting of it under
protection of sc->mtx.  Sometimes multiple insert/ejections could
cause further insertion/removals to not happen due to racing an ISR...
2003-08-18 03:15:44 +00:00
Warner Losh
fbe1513849 trivial optimization: use nameunit here. 2003-08-14 07:15:19 +00:00
Warner Losh
8a0ef7be56 MF p4:
Minor style(9) nit.
2003-08-10 03:47:29 +00:00
Warner Losh
2724f3214d Some bridges, like o2 micro and maybe ricoh, have some issues between
the time the card is inserted and the time that the card is
configured.  This can lead to interrupt storms.  The O2Micro suggested
workaround is to route the card function interrupt to IRQ1.  It
appears from my testing that this is an acceptable workaround for most
chipsets (there's still some issue with the ricoh chipset).

Also, only look at the NOT_A_CARD bit when the bridge tells us there's
a card present.  At least one test caused this to be true after the
card was removed, but the author couldn't recreate it with the
workaround in place.  The change is more conservative than the
previous code, but still has the work around that wasn't present in
the older code.
2003-08-10 02:40:49 +00:00
Warner Losh
fda5b6124b Add code to cope more with strange conditions after careful study of
the standard.

1) When the bridge tells us that we have a card that isn't recognized, we
   use the force register to force the CV_TEST to run.  This test causes the
   bridge to re-evaluate the card.  Once this re-evaluation process happens,
   we get a new interrupt that may say it is ready to process.  We try this up
   to 20 times.  Tests have shown that this appears to correctly reset the
   'Unknown card type' problem that I saw on my Sony PCG-505TS.
2) Take a page from OLDCARD and always read the CSC register in the ISR.
   Some TI (and it seems maybe Ricoh) chipsets require this to behave
   properly.  This work around appears to work due to some power management
   protocols that were improperly implemented.  Maybe it can be removed when
   this driver supports the full PME# protocol described in the standards.
3) Minor additional debug printf when debugging is enabled.
4) Minor additional commentary for things that are obvious only after study.

# I'm committing this from my Sony PCG-505TS using shared PCI interrupts
# and NEWCARD, but there are some issues with the Ricoh bridge still, but
# at least now I can boot with the card inserted and have it work.
2003-08-09 21:05:54 +00:00
Warner Losh
71ed0ee3da CBB_SOCKET_STAT_ is too long. Change it to CBB_STATE_. Also, make
some minor changes to more closely match the bit names used in the 7.0
version of the PCMCIA standard.  Also add bits from the FORCE
register.
2003-08-09 20:49:22 +00:00
Warner Losh
69a7c91e70 When allocating memory, align it to the minimum alignment required for
cardbus bridges if the alignment requirements were less restrictive.
2003-08-09 20:38:53 +00:00
Warner Losh
da57cf7c7e Add comments about some alignment that looks a little strange. 2003-08-09 20:33:53 +00:00
Warner Losh
e3bf57b6c9 Minor fixes to a couple of comments. 2003-08-09 20:31:25 +00:00
John Baldwin
8b149b5131 Consistently use the BSD u_int and u_short instead of the SYSV uint and
ushort.  In most of these files, there was a mixture of both styles and
this change just makes them self-consistent.

Requested by:	bde (kern_ktrace.c)
2003-08-07 15:04:27 +00:00
Warner Losh
fa4b32fa80 All current uses of pci_set_powerstate are bogus, at least in theory.
However, they are presently necessary due to bigger bogusness in the
pci bus layer not doing the right thing on suspend/resume or on
initial device probe.  This is exactly the sort of thing that the
BURN_BRIDGES option was invented for.  Mark all of them as
BURN_BRIDGES.  As soon as I have the powerstate stuff properly
integrated into the pci bus code, I intend to remove all these
workarounds.
2003-07-03 14:00:57 +00:00
Warner Losh
2b8c22f66c Unlock after ISR.
Noticed by: njr
Pointy hat to: the impable one.
2003-06-12 06:06:14 +00:00
Warner Losh
9b6df37a1a s/BURN_THE_BOATS/BURN_BRIDGES/g to adopt to new world order 2003-06-12 05:44:30 +00:00
Warner Losh
de5059db1c Make cbb interrupts MPSAFE:
o Register ISR INTR_MPSAFE.
o Loop on KTHREAD_DONE == 0 in the thread.
o Safe the INTR_MPSAFE flag for client drivers (don't know if there are any
  CardBus/PCI drivers that are INTR_MPSAFE)
o Read status after acquiring mtx_lock(Giant) rather than before so that we
  catch state changes that happen while Giant is being acquired.
o Turn off the CD bit when we see a CD interrupt, and turn it back on after
  we've attached/detached the card.
o On suspend, actually set the CBB_SOCKET_MASK to zero rather than oring
  in '0' to turn it off on suspend.
o If the ISR that's registerd is MPSAFE, don't acquire Giant around call to
  client ISR.
o Fix comments to reflect these changes.
2003-06-12 03:37:28 +00:00
Warner Losh
e08a16f0df MFp4:
Migrate some common pccard code into exca.
2003-06-07 20:47:35 +00:00
Warner Losh
bb22b14154 Simplify the power code somewhat (this makes the module about 100
bytes smaller).
2003-06-07 20:18:45 +00:00
Warner Losh
e4e7b5bc54 Add two of three workarounds for interrupt storms for o2micro parts as
obtained from o2micro.  These should only be needed for 'older'
o2micro bridges (anything before the 7xxx series of bridges), but will
work with the new bridges.

# I don't plan on porting it to oldcard, but will happily commit to
# oldcard if someone else needs them.
2003-06-06 06:00:49 +00:00
Poul-Henning Kamp
4738f8c1a8 Remove return after goto.
Remove break after return;

Found by:       FlexeLint
2003-05-31 20:35:32 +00:00
Warner Losh
efc7a12c6d Back out accidentally committed debugging 2003-05-04 23:58:37 +00:00
Warner Losh
452855111a fix typo in TI1515 ID. 2003-05-04 12:49:37 +00:00
Warner Losh
cf808dab3f Grab some of the latest TI cardbus bridge IDs. Inspired by a similar
commit to NetBSD.  I'll add these to various tables soon.
2003-05-04 06:10:05 +00:00
Warner Losh
c7611918c1 Fix typo on O2Micro devices names.
Submitted by: noda-san
2003-04-29 05:59:04 +00:00
Warner Losh
5878ce2cec Make IRQ shareable for the cardbus case too. 2003-04-28 18:50:59 +00:00
Warner Losh
307def65f1 Don't need to read this config register if we're just going to
overwrite it in the next line.
2003-04-08 06:54:10 +00:00
Warner Losh
9713a7922e MFp4: Massively unbreak module loading/unloading:
o Only complain about detached children that aren't pccard/cardbus.
o Don't NULL out the pccarddev and cbdev devices.  detach just
  disassociates the device and driver.  It doesn't delete the child.
o on driver added, just probe_and_attach the children.  If there's
  any children attached, wakeup the device add/delete thread.
o wakeup the add/delete thread with the correct cv_signal() rather
  than the bogus wakeup(sc).  It used to be that we did a tsleep on
  sc in this thread, but switched to the more reliable cv stuff a while
  ago w/o changing this.
o Remove bogus checks when reallocating memory for the registers.  They
  weren't needed and turned out to be completely bogus.

This lets me load/unload pccard with a pccard in a slot and have the
child correctly detach/attach.  This should help people that have wi
in their kernel, but that kldload cbb and pccard, for example.
2003-04-08 06:52:16 +00:00
Warner Losh
d705fb0577 Add a number of IDs from linux for old, rare pci devices:
o A second 82092AA id.
o SMC 34c90
Plus a couple of trivial formatting changes.
2003-02-26 05:44:00 +00:00
Warner Losh
2ff0908a66 o transition from exca_write to exca_putb and read->getb. This is so that
we can have additional different types of bridges.
o remove now bogus comment.
o Don't clear CARD_OK when we can't attach a card.
o minor style nits

# this make kldload of cardbus drivers work for me when the card is
# present on boot.
2003-02-14 06:21:51 +00:00
Warner Losh
e961d904ac Remove a comple of bogus debug printfs that snuck in during some
debugging I was doing 3 months ago :-(.

Noticed by: scottl
Aproved by: the re blanket (different than the security blanket).
2002-11-23 23:09:45 +00:00
Warner Losh
b20360c8e6 MFp4:
o Add support for bus_child_present call by implementing that method for cbb.
2002-11-14 05:20:39 +00:00
Warner Losh
dfe5056e80 MFp4:
o Make this code a little easier to understand by using simpler if
  statements, but nesting them.
2002-11-14 05:18:53 +00:00
Warner Losh
518792d85c Detach the pccard bus children when we eject a 16-bit card, not the
32-bit ones.  This was introduced in the last commit.
2002-11-04 03:01:56 +00:00
Warner Losh
bcaa6b0541 MFp4:
o Always release the resources on device detach.
o Attach resources the same with driver added as we do we do in the insert
  case (maybe this should be a routine).
o signal the wakeup of the thread on resume instead of trying to force an
  interrupt.
o Minor debug hacks.
o use 0xffffffff instead of -1 for uint32_t items.
o Don't complain when we're asked to detach no cards.  This is normal.
o Eliminate the now worthless second parameter to card_detach_card.
o minor style(9)isms

Some of these patches may be from: iwasaki-san, jhb, iadowse
2002-11-02 23:00:28 +00:00
Warner Losh
93642ba9bf o Set CBB_CARD_OK just before CARD_ATTACH_CARD. If ATTACH_CARD fails, then
clear the bit.  This allows ata driver to attach its children because
  it needs the interrupts enabled to succeed.

Submitted by: iwasaki-san

o Spell CardBus as CardBus, not Cardbus or CardBUS while I'm here.
2002-10-11 04:30:59 +00:00
Warner Losh
c4598a8916 Make kldunload cbb work:
o Implement the thread killing interlock as described by jhb in arch@
  while talking to markm.
o Hold Giant around cbb_insert()/cbb_remove().  Deep in the belly of
  the vm code we panic if we don't hold this when we activate the memory
  for reading the CIS.
o If we had to do the kludge alloc, then do a kludge free.
2002-10-08 03:53:52 +00:00
Warner Losh
01d8ff4dfd MFp4:
o Better resume code.  Move the comments around.  Force the socket state to
  be querried.  Ack the interrupts properly.
o Intercept the interrupt requests and keep a list of interrupts to service
  ourselves.  When the card attaches, set its OK bit.  When we get a card
  status change interrupt for that card, clear the OK bit.  Don't call the
  ISR if the OK bit is cleared.  Iwasaki-san and yamamoto-san have both
  sent me patches that fix the same problem this fixes, but at the pccard
  level.
o Try to get the signalling of the thread to actually die.  This might not be
  100% right, but it is less wrong than before.
o Add a SIC next to a TI type that looks like it could be wrong, but isn't.
2002-10-07 23:11:29 +00:00
Scott Long
316ec49abd Some kernel threads try to do significant work, and the default KSTACK_PAGES
doesn't give them enough stack to do much before blowing away the pcb.
This adds MI and MD code to allow the allocation of an alternate kstack
who's size can be speficied when calling kthread_create.  Passing the
value 0 prevents the alternate kstack from being created.  Note that the
ia64 MD code is missing for now, and PowerPC was only partially written
due to the pmap.c being incomplete there.
Though this patch does not modify anything to make use of the alternate
kstack, acpi and usb are good candidates.

Reviewed by:	jake, peter, jhb
2002-10-02 07:44:29 +00:00
Warner Losh
b5b0634309 reprobe not needed here either 2002-09-10 06:37:56 +00:00
Marc Fonvieille
1739cac24b Fix typos: s/O2Mirco/O2Micro/
Approved by:	imp
2002-08-24 07:46:08 +00:00
Warner Losh
b35cf6719f Rename the pccbb device to cbb. 2002-08-15 08:01:24 +00:00
Warner Losh
673cffefc7 When we allocate our bus address via the kludge that we have in the
code to do it when the bios doesn't do it for us, flag it.  Then, when
we dealloc, do an equal kludge to get rid of the address.  This should
address the can't get IRQ and panic bug in a more graceful way.

# really should write a dealloc routine and just call it instead, since
# this might not fix things in the kldunload case.
2002-08-10 06:37:32 +00:00
Warner Losh
44d0da39f0 confirmed OZ6912 and 6972 share same pci ID 2002-08-10 06:35:03 +00:00
Warner Losh
3722c8ed3d No doubt about it, I gotta get a better hat:
Add the definition for sockbase that I accidentally removed two
revisions ago and didn't notice until some kind soul pointed it out to
me.
2002-07-26 20:28:58 +00:00
Warner Losh
8948a4fd3d Looks like a last second change wasn't completely backed out. 2002-07-26 17:50:01 +00:00
Warner Losh
e4188e915d MFp4:
o Rename the insanely long PCIC bridge ids.
	o Add my copyright to pccbb.c
	o Add support for the TI-1510, TI-1520 and TI-4510 series of upcoming
	  bridges.
	o Init MFUNC if it is zero and the TI part has a MFUNC register
	  at offset 0x8c (1030, 1130 and 1131 don't have anything there, the
	  1250,1251,1251B and 1450 have a different thing there.  The rest
	  have it.  TI is likely to only do MFUNC from now on.  The IRQMUX
	  in the 1250 series of chips needs no tweaks.
	o Adjust to new exca interface.
	o Add comments about TI chips that I learned in talking to an
	  engineer at TI.
	o Add register definitions for MFUNC.
	o Create CB_TI125X chipset type.
2002-07-26 08:05:25 +00:00
Warner Losh
9e1b56e284 Reset the 16-bit bus and turn off power. More work in this area may
be needed, but this seems sane on my laptop.
2002-07-21 04:23:11 +00:00
Warner Losh
4fdc73e4fa Use a cv rather than tsleep and friends to do the sleep/wakeup
handshake between the ISR and the worker thread.  Move the mutex lock
so that it only protects the cv_wait.  This elimiates the not sleeping
with pccbb1 held messages some people were seeing.

Reviewed by: jhb (at least an early version)
2002-06-13 07:19:31 +00:00
Takanori Watanabe
80f1001813 Make oldcard and newcard kernel module work. 2002-05-30 17:38:00 +00:00
Warner Losh
d76b2f9d54 Spell hw.cbb.start_memory the same in the HINT as well as the sysctl.
Noted by: bde
2002-04-29 07:41:58 +00:00
Warner Losh
9ce2d50cf2 Make sysctl RW 2002-04-29 07:37:09 +00:00
Warner Losh
387a5bacc2 Restore NetBSD copyrights that shouldn't have been removed in the first place. 2002-04-13 04:07:07 +00:00
John Baldwin
6008862bc2 Change callers of mtx_init() to pass in an appropriate lock type name. In
most cases NULL is passed, but in some cases such as network driver locks
(which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used.

Tested on:	i386, alpha, sparc64
2002-04-04 21:03:38 +00:00
Warner Losh
4d8f4de40e Check the status of the card bridge first thing, rather than last in
the loop.  This fixes the "my card is in the laptop on boot, but
doesn't attach" problem.
2002-02-20 16:20:27 +00:00
Warner Losh
c92e45e4a1 Bulk changes made during the BSDcon kernel summit and travel afterwards.
Appologies for making this one bulk commit, but I have tested all these
changes together and don't want to break anything by trying to disentangle
it.

o Make debugging a sysctl/tunable
o Remove flags word from yenta chip info, it is unused
o Make 16-bit card I/O range and 32-bit card I/O range tunables
o Start the rename of pccbb to cbb to match NetBSD by misc renames.
o Kill the now bogus list of softcs to create kthread.  Instead, just
  create the kthread in the attach routine.
o Remove sc_ from some structure names.  It isn't needed.
o Refine chipset lookup code.
o Match generic PCI <-> CardBus bridges.  We specifically don't generically
  match PCI PCMCIA bridges because they are not, with one exception, yenta
  devices.
o Add some comments about the why we need to have a function table ala
  OLDCARD
o The PCI interrupt routing by using the ExCA registers is needed for
  for all bridges, per the spec, not just TI ones.
o Collapse TOPIC95 and TOPIC95B.
o Using the ToPIC 97 and 100 datasheets, try to support these bridges better,
  but more work is needed.
o Generally clarify some XXX comments and add them in a few places where
  things didn't look right to me.
o Move interrupt generating register access until after we establish an ISR.
o Add support for YV and XV cards.  X and Y are numbers to be determined
  later (but maybe never).
o factor powerup code for 16-bit and 32-bit cards.
o When a card supports more than one voltage, prefer the lowest supported
  volage.  Windows does this, and MS's design guides imply this is the
  right thing to do.
o Document race between kthread_exit(0) and kldunload's unmapping of pages
  that John Baldwin and I discovered.
o Debounce the CSC interrupt a little better.
o When a 16-bit card is inserted when we don't have a pccard child,
  warn about it better.  Ditto for 32-bit card.
o Ack ALL the interrupt bits that we get, not just 0x1.
o maybe a couple minor style nits corrected.
2002-02-17 03:11:11 +00:00
Dag-Erling Smørgrav
7d8aca49fc I am sick of being told that "cstsevent occures". 2002-02-16 23:00:27 +00:00
Warner Losh
cebd67fba3 o Use INTR_TYPE_AV (the highest possible) rather than INTR_TYPE_BIO
o Don't allow INTR_TYPE_FAST.  Since we are sharing the interrupt between
  CSC and the functions, they can't be FAST because fast interrupts can't
  be shared.
o Add the same workaround for resume that we have in OLDCARD.
o Also, return the error from bus_generic_resume rather than ignoring it.
2002-02-10 03:28:37 +00:00
Warner Losh
a0e457a620 Default debugging to OFF now. 2002-02-04 15:55:21 +00:00
Warner Losh
473a3d8520 Migrate towards using the new exca module for 16bit stuff. This is a
WIP, but works for me.

Also do some minor code factoring and code cleanup while I'm here.
2002-01-29 06:50:18 +00:00
Warner Losh
fa3433e1db Minor sorting orders 2002-01-29 06:15:07 +00:00
Warner Losh
5d4be85d55 better namespsace of static functions 2002-01-15 20:41:39 +00:00
Warner Losh
2bef11b863 o Sync the device list with OLDCARD.
o Remove bogus flags that aren't used (if we need them in the future, we can
  add them back).
o Add support for the TI-1031.  This is the only YENTA compatible PCI-PCMCIA
  bridge that I'm aware of (all the others are PCIC on a PCI bus, which is
  different).
2002-01-15 20:21:43 +00:00
Warner Losh
6015f06948 use bus_space(9) rather than the memory mapped register set. This is
the first step towrads merging pcic and pccbb for 16-bit cards.
2002-01-14 02:59:06 +00:00
Warner Losh
a432b68b87 Add support for suspending/resuming CardBus bridges.
We really should have and use power state information, but none exists
today.

Submitted by: YAMAMOTO Shigeru-san <shigeru@iij.ad.jp>
2001-12-15 05:58:28 +00:00
Warner Losh
969c260d72 Make the start memory address that we use configurable via a boot
loader parameter.  This allows us to more easily boot on big memory
configuration machines.  hw.pccbb.start_mem.  Reflect this in a sysctl
so we can read it from userland.

# Note: we need a TUNABLE_ULONG to do this right.  I'll add that to
# kernel.h soon.
2001-11-26 07:17:09 +00:00
Warner Losh
72905c7ec4 style(9) fixes:
o declare variables at the start of the function, not the start of
	  a block.
	o return (retval);
	o minor {} tweaks.
2001-11-26 05:42:45 +00:00
Warner Losh
746509ce98 peter pointed out that I missed a hard coded location for the memory.
Also add a define for I/O stuff (for cardbus).
2001-11-26 02:11:22 +00:00
Warner Losh
b772be119c Make the address we kludily allocate in pccbb be a #define for easier
changing.  Also change it from 0x44000000 to 0x84000000 for large memory
machines.

# the PCI bus code should do this for us.  This is a bandaide, not a
# solution.
2001-11-26 00:33:04 +00:00
Warner Losh
f966c94291 Move Intel 82092AA into the list of devices. It appears to be a one
off chip that was on one prototype board.  However, this appears to be
a design that many chipsets are compatible with its PPEC register set
(eg the Omega 82c094).  Through the kindness of the Red Hat developer
David Woodhouse, I now have this datasheet.

I may take the advise of one of the bsd-nomads (whose name
unfortunately escapes me at the moment) and split out all these 16-bit
I/O mapped PCI devices into a separate driver...
2001-11-11 17:45:55 +00:00
Warner Losh
e655dc959a Add Omega 82c094 PCI PCMCIA bridge. It is similar to the CL-PD6729 in
that it has one BAR that's mapped to 0x3e0 and is I/O only.  It does
not conform to the Yenta spec, like other PCI PCMICA bridges do (eg
the TI 1031, which is mostly a 1131 w/o 32bit card support).  It
appears that this chip may also need to not route PCI interrupts
as well.

This chip is used in the NEC Versa 2430CD (and it appears that
sometimes it works, while other times it doesn't) and others in the
2400 series.  While the NEC website claims Cardbus support, I can't figure
out how that is possible.

Submitted by: Ben Timby <ben@webexc.com>
2001-11-11 17:07:43 +00:00
Poul-Henning Kamp
9d1efefd21 Add PCIC_TI4410
(patch probably from imp@, can't remember figuring this out myself.)
2001-11-03 16:45:31 +00:00
Warner Losh
ceeb222ab4 Surf the net again and find more device IDs:
Cirrus Logic PD6834
O2micro OZ6836
O2micro OZ6912/6972
O2micro OZ6922
O2micro OZ6933
TI1260			Note: These two aren't on TI's site, but are in
TI1260B			http://www.yourvote.com/pci/vendors.txt

Plus comments for other chips found in Windows INF files, and also
referenced in various spots on the net:

 *   Intel		82092AA		0x12218086	16bit
 *   smc/Databook	DB87144		0x310610b3
 *   SMC/databook	smc34c90	0xb10610b3
 *   Omega/Trident	82c094		0x00940123?
 *   Omega/Trident	82c194		0x01941023
 *   Omega/Trident	82c722		0x07221023?
 *   Opti		82c814		0xc8141045
 *   Opti		82c824		0xc8241045
 *   NEC		uPD66369	0x003e1033
2001-09-06 20:50:10 +00:00
Warner Losh
df6567b786 minor commentary 2001-09-06 20:43:12 +00:00
Warner Losh
9a25341262 First, The Ricoh 5C47x chips don't have the disable the 3e0 bits.
Second, the TI 1130 need to have the PCI_INTR set, not cleared.

This gets Soren's machine working with NEWCARD again.

# The whole initialization is a mess and needs to be organized ala OLDCARD.
2001-08-29 20:33:08 +00:00
Jonathan Chen
472ce770c4 Fix the hack that allocates memory when the bios haven't already done so.
We can't rely on rman to give us a useable memory window if we tell it to
do auto-allocation.  This should probably be fixed on the pci bus/rman side.
2001-08-27 11:23:05 +00:00
Warner Losh
db3e31829d Note difficulties we had in OLDCARD using NEWCARD's methods of debouncing card event interrupts. 2001-08-27 01:30:46 +00:00
Jonathan Chen
63fa9f4c0d Part two of this NEWCARD update:
Briefly, the significant changes include:
 * Way better resource management in pccbb, pccard and cardbus.
 * pccard hot-removal now appears to work.
 * support pre-fetchable memory in cardbus.
 * update cardbus to support new pci bus interface functions.
 * Fix CIS reading to no longer use rman_get_virtual().

What's not there, but in the works:
 * pccard needs to do interrupt properly and not read the ISR on single
   function cards.
 * real resource management for pccard
 * a complete implementation of CIS parsing
 * need to look into how to correctly use mutex in pccbb
2001-08-27 00:09:42 +00:00
Jonathan Chen
255b159f5f Non-functional changes to NEWCARD stuff.
This is the first part of a two-part update to NEWCARD.  Changes in this
commit are non-functional, and includes the following:
 * indentation and other changes to meet style(9).
 * other minor style consistancy changes
 * addition of comments
 * renaming of device_t variables to be consistant across all of NEWCARD.

(note that not all style violations are fixed in this commit -- those that
 aren't will be clobbered by the next commit.)
2001-08-26 23:55:34 +00:00