Commit Graph

150 Commits

Author SHA1 Message Date
joerg 16951292eb Remove a completely bogus check if cbb has a valid PCI interrupt routed.
If you have a system where it doesn't get one and you still want pcic,
you can just disable cbb. This check is invalid as soon as the PCI
interrupt register is not used and broke on my Dell Latitude for that
reason.
2007-10-25 13:49:06 +00:00
joerg dcf90eeb82 Correctly initialise sc_insert_ch and switch to
callout_setfunc/callout_schedule.
2007-10-22 14:03:51 +00:00
ad a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
dyoung 75929630cc Read the PCI latency timer from the right register, using the right
macro.
2007-08-11 00:45:35 +00:00
dyoung abb1098904 Make pccbb(4) use more PCI configuration register definitions,
especially the Bridge Control Register definition, instead of
rolling its own.

As we read/modify/write configuration registers, use a variable
that is named for the register we're r/m/w'ing, instead of using
the variable 'reg' over and over.  This helps both a human reader
verify that we're not reading register X, modifying it, and writing
back to register Y (oops); the compiler can help a little by warning
that a variable is used before it is initialized.
2007-08-11 00:31:04 +00:00
christos 1737a18597 PR/36652: Dave Barnes: cbb0: Bad Vcc status once set will not clear
-ThinkPad 570 / PC: Don't write to SOCKET_STAT, which is read-only,
instead write to SOCKET_FORCE.
2007-07-16 14:36:01 +00:00
dyoung fa956bd2bd Fix a bug in Cardbus power activation.
Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'.  TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt.  When pccbb_power() powered-up a
cardslot, it did wait for the interrupt.  If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0:  power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete.  After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up.  An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

        /*
         * Wait as long as 200ms for a power-cycle interrupt.  If
         * interrupts are enabled, but the socket has already
         * changed to the desired status, keep waiting for the
         * interrupt.  "Consuming" the interrupt in this way keeps
         * the interrupt from prematurely waking some subsequent
         * pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

         * XXX Not every bridge interrupts on the ->OFF transition.
         * XXX That's ok, we will time-out after 200ms.
         *
         * XXX The power cycle event will never happen when attaching
         * XXX a 16-bit card.  That's ok, we will time-out after
         * XXX 200ms.
         */

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
2007-02-04 21:04:37 +00:00
dyoung 954e7e37ab Cosmetic: KNF indentation, curly braces, and argument declarations. 2007-02-04 05:34:38 +00:00
dyoung 441215d99b Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().
2007-02-04 05:08:18 +00:00
dyoung b39ec50ca6 Use the right subroutine name for the debug message. 2007-02-04 04:59:39 +00:00
dyoung d5268f7ddd Fix grammar in comment. From Patrick Welche. 2007-01-26 02:27:29 +00:00
dyoung 6a0ae17676 Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR. 2007-01-26 02:04:44 +00:00
yamt 8bf7662829 merge yamt-splraiseipl branch.
- finish implementing splraiseipl (and makeiplcookie).
	  http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
	- complete workqueue(9) and fix its ipl problem, which is reported
	  to cause audio skipping.
	- fix netbt (at least compilation problems) for some ports.
	- fix PR/33218.
2006-12-21 15:55:21 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
itohy fc1ed5259e 3c575CT Ethernet card requires a little more time during reset
and after reset, or the card won't be detected on some machines.
Change the time from 40ms to 50ms.

XXX The card doesn't work correctly yet.
2006-10-24 14:16:39 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
jmcneill f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +00:00
christos 160a42523a - Tidy up some debugging/diagnostic messages.
- Add a delay for the topic95b after we power on. It makes things work without
  CBB_DEBUG on!
2006-07-08 23:02:55 +00:00
christos ff1066c12a - all the polling code is stale and broken. Mention it.
- the topic95B bridge does not set CB_SOCKET_STAT_PWRCYCLE
- put back the delay code that was removed *again*.
This makes my libretto 100CT work again.
2006-07-08 20:20:27 +00:00
christos d16c773e0b fix typo 2006-07-04 00:47:47 +00:00
christos 01158ea892 Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
2006-07-04 00:30:21 +00:00
jmcneill efd8b75c34 For Ricoh 5c47x class controllers, restore the "misc control" PCI config
register on resume.
2006-06-17 17:06:51 +00:00
dyoung 9f1cdb7a4a Fix typo in comment, s/will be never/will never/. 2006-04-05 22:16:42 +00:00
sekiya 5f1ddaf57b Use aprint_debug() instead of printf() for obvious debug statement. 2005-12-18 11:04:00 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
drochner 1af44f3c6e remove the useless (always 0) device number from cardbus driver state,
autoconf attach structures and configuration cycle functions
(just leave the kernel configuration attribute for now to avoid breaking
 config(1) files)
2005-09-09 14:50:58 +00:00
wiz 006993c282 s/PCIBIOS_FIXUP/PCI_FIXUP/ in printf, from Patrick Welche in PR 30583. 2005-06-23 14:20:23 +00:00
sekiya 090f77819b Oops, a unilateral DEBUG define crept in with my last commit. 2005-06-22 22:57:17 +00:00
sekiya 93ed08ce8d Don't abort the attach if we are routing interrupts through the ioapic, there 2005-06-20 09:18:36 +00:00
sekiya 58a736f2b9 Fix compilation problem when CBB_DEBUG is defined. 2005-06-01 09:10:57 +00:00
sekiya e1dc11af89 "resister" -> "register" 2005-06-01 08:39:32 +00:00
christos bb4c90071c - const poisoning
- avoid variable shadowing.
2005-05-30 04:35:22 +00:00
christos 5586266e3c PR/29600: YAMAMOTO Takashi: cbb hangs on boot. From the PR:
It seems that we never get a power interrupt for 16 bit cards. The tsleep
has been changed to wait for 200ms maximum, before giving up instead of
waiting forever. XXX: Maybe that is too small for some laptops?
2005-03-23 20:53:19 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
perry 18db93c7f6 de-__P 2005-02-04 02:10:35 +00:00
jmcneill fac3e15af3 Fix typo. 2005-01-27 03:03:33 +00:00
jmcneill 7f3681fe2b Don't restore PCI configuration state if the chip isn't in D0, from
Kentaro A. Kurahone.
2005-01-27 02:58:52 +00:00
jmcneill 27d1abf7f8 Capture PCI configuration state on suspend and restore it on resume, from
Kentaro A. Kurahone.
2005-01-27 02:44:59 +00:00
mycroft ea0b1cb353 Just to be absolutely correct, wait an additional 1ms after the "power cycle"
event, to cover the RESET Width (Tw (RESET)).
2005-01-16 08:56:29 +00:00
mycroft b0345c674e Christos's crappy Libretto 100CT has an extremely long ramp for socket Vcc
(violating the PC Card spec), so... use the "power cycle" socket event to
determine when we've reached Vcc before proceeding, rather than using a fixed
amount of time.  This has the double advantage that it makes the card attach
time even shorter on sane systems -- the minimum is now ~38ms on my i8500
rather than 222ms.

Probably a similar change should be made to pcic, but it was hard enough
figuring out whether it would work with pccbb.  The chip specs suck.

For now, I'm leaving in a couple of additional printf()s in the hope that I
will get some interesting data from them.
2005-01-16 08:51:55 +00:00
mrg 2db238d57d fix a wrong variable name in a debug message. 2004-08-16 16:43:29 +00:00
mycroft 5111abd827 Simplify some manipulation of PCIC_INTR.
Further attempt to mitigate "bad Vcc" errors.
2004-08-16 15:46:37 +00:00
mycroft f0b8d692af Some tweaks, per the PC Card spec:
* Assert RESET before powering off a socket.
* Turn on the output enable bit earlier so the interface actually drives CEn
  and RESET.
* Tighten up the power-on timing a bit.
* Mention the specific timing values named in the spec.

For pccbb, be careful to always power off before zeroing PWRCTL.
2004-08-16 15:40:35 +00:00
mycroft 4ff9d12ea9 Do not attempt to fiddle with the power-control bits in PWRCTL; just read them
back after touching the PCI registers.

This shouldn't be necessary, but somehow the controller detects the need for
VPP2=12V and automatically applies it, and gives us a "bad Vcc" error if we
turn it off accidentally.
2004-08-16 14:48:56 +00:00
mycroft a6f02be621 And the reason we had to call pccbb_power() twice in the enable routine is...
we were writing to PCIC_PWRCTL in between and causing the socket to power off.
D'oh.
2004-08-15 20:19:14 +00:00
mycroft 306522b970 I can't actually use the FORCE register this way. Just try turning the socket
power off.
2004-08-12 13:42:17 +00:00
mycroft 6b8a90b3fe A bunch of random cleanup:
* Like the i82365 code, add a "delay" function that uses tsleep() to wait, and
  use this in the socket enable/disable paths.  This gets rid of the annoying
  system pauses during card insertion and removal.  (There are still some
  issues related to this in various drivers -- notably big delay()s in wi and
  xi.)
* Move the power-change delay out of pccbb_power() and into the PCMCIA backend
  code -- specifically, once in the disable path and once in the enable path.
  We were being pretty schizo about this before.  Make these use tsleep().
  (Note: This should be safe because card insertion/removal is handled by a
  kernel process, not in an interrupt handler.  It works for me with
  DIAGNOSTIC.)
* If we get a "bad Vcc" error, attempt to force the socket to power off, and
  return an error.  If we don't do this, we will get "bad Vcc" errors forever
  and never be able to use another card without rebooting, which is dumb.
  XXX I haven't been able to test this very well, because it doesn't fail for
  me in the first place.  :-)
* Clean up the socket mappings earlier in the enable path.
* Try to be consistent about clearing PWRCTL (which contains OE) before turning
  off power.
2004-08-12 07:15:49 +00:00
mycroft 33ee9cbce7 Oops; fix a compile error. 2004-08-11 01:05:42 +00:00
mycroft 51be90e8ac Be more liberal in torching the old state in the disable and settype routines. 2004-08-11 01:04:40 +00:00
mycroft a23e15bcbe Rather than having a call up from the low-level driver to get the card type,
instead have a call down from the PCMCIA mid-layer to set it.  Use this from
pcmcia_function_enable().  (Currently the policy is the same, but this would
allow for more flexibility in deciding which mode to use.)

Now it is safe to hold the socket enabled during attach, so do that.  Only
one enable/disable cycle to attach a card now!
2004-08-11 00:18:18 +00:00