Commit Graph

102 Commits

Author SHA1 Message Date
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