History log of /openbsd-current/sys/dev/pci/pccbb.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.105 24-May-2024 jsg

remove unneeded includes; ok miod@


# 1.104 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.103 11-Mar-2022 mpi

Constify struct cfattach.


# 1.102 02-Feb-2022 jsg

unifdef __NetBSD_Version__


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.101 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.104 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.103 11-Mar-2022 mpi

Constify struct cfattach.


# 1.102 02-Feb-2022 jsg

unifdef __NetBSD_Version__


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.101 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.103 11-Mar-2022 mpi

Constify struct cfattach.


# 1.102 02-Feb-2022 jsg

unifdef __NetBSD_Version__


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.101 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.102 02-Feb-2022 jsg

unifdef __NetBSD_Version__


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.101 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.101 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.100 20-Mar-2020 cheloha

pccbb.c: tsleep(9) -> tsleep_nsec(9), timeout_add(9) -> timeout_add_nsec(9)

Straightforward ticks -> milliseconds conversions.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.99 05-Jan-2020 jsg

consistently uppercase pci product defines

ok mpi@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.98 17-Jul-2018 dlg

we have splraise() now

previously the code would do a series of comparisons to IPL_FOO and
IPL_BAR, and use splfoo() and splbar() as needed, but for like a
dozen different IPl levels (i may be exaggerating). splraise() rolls
all of that up.

ok deraadt@ mpi@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


Revision tags: OPENBSD_6_2_BASE
# 1.97 08-Sep-2017 deraadt

If you use sys/param.h, you don't need sys/types.h


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.96 11-Sep-2015 deraadt

fairly simple size for free()


Revision tags: OPENBSD_5_8_BASE
# 1.95 20-Jul-2015 kettenis

Try to assign a secondary bus number if the BIOS left the CardBus bridge
unconfigured.

ok miod@, mlarkin@


# 1.94 19-Jul-2015 bcook

simplify a triple-deep ternary operation.

ok beck@ krw@


# 1.93 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.92 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


Revision tags: OPENBSD_5_5_BASE
# 1.91 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.90 30-Oct-2013 mpi

Replace workqs with tasks.

ok dlg@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.89 18-Oct-2012 deraadt

Use pci_set_powerstate() unconditionally for all chip variants, rather
than a kludged together chunk of code for just one chip, which happens
to be entirely wrong. We need to watch for regressions on cardbus, though.
ok kettenis


# 1.88 08-Oct-2012 deraadt

Revamp the sequences for suspend/hibernate -> resume so that the code
paths are reflexive. It is now possible to fail part-way through a
suspend sequence, and recover along the resume code path.
Split DVACT_SUSPEND by adding a new DVACT_POWERDOWN method is used
after hibernate (and suspend too) to finish the job. Some drivers
must be converted at the same time to use this instead of shutdown hooks
(the others will follow at a later time)
ok kettenis mlarkin


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.87 08-Dec-2010 miod

Fix compilation with option CBB_DEBUG; noticed by Dave Anderson on misc@


# 1.86 20-Sep-2010 matthew

Get rid of evcount's support for arranging counters in a tree
hierarchy. Everything attached to a single root node anyway, so at
best we had a bush.

"i think it is good" deraadt@


# 1.85 08-Sep-2010 deraadt

Document that the resume case is waking children which may have been
ejected, and that this needs to be solved.


# 1.84 08-Sep-2010 deraadt

Split out the guts of pccbbintr() so that we can call it carefully at
resume time.
ok kettenis


# 1.83 08-Sep-2010 deraadt

During suspend, do not call children's interrupt handlers after we have
told them to suspend. In some drivers, this "wakes" them up.
ok kettenis


# 1.82 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.81 06-Sep-2010 kettenis

Save and restore pci config space registers common to all PCI-CardBus
bridges when we do suspend and resume.

ok deraadt@


# 1.80 03-Sep-2010 kettenis

Some cleanup in preparation for suspend/resume improvements.


# 1.79 31-Aug-2010 deraadt

convert the powerhook to an activate function. That activate function
does not truly work yet many machines because it does not do enough; it is
a total fluke if it works for you. (kettenis is, I think, working on
improving it)
ok kettenis


# 1.78 27-Aug-2010 deraadt

kill PWR_STANDBY (apm can use PWR_SUSPEND instead). While here, renumber
PWR_{SUSPEND,RESUME} so that they match the values of DAVCT_{SUSPEND,RESUME}
so that we can eventually (many more steps...) kill the powerhook garbage
and use the activate mechanism.
no objections


# 1.77 25-Aug-2010 kettenis

Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road
towards fully suspending CardBus on all machines.

ok deraadt@, damien@


Revision tags: OPENBSD_4_8_BASE
# 1.76 30-Jun-2010 blambert

timeout_add -> timeout_add_msec

"I agree that hz / 10 is 1/10 of a second, which is 100 milliseconds" krw@


# 1.75 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


# 1.74 27-Mar-2010 jsg

Give cardbus the pci_chipset_tag_t from pccbb and push it out through
cardbus_attach_args so we can switch to using proper pci config
space functions instead of callback based wrappers.

ok oga@ krw@ kettenis@


# 1.73 27-Mar-2010 jsg

Bring back cardbus_chipset_tag_t which is in practice a
pointer to the pccbb softc, to distinguish it from a pci_chipset_tag_t
which can be passed to the normal pci functions.

Suggested by and ok kettenis@


# 1.72 23-Mar-2010 krw

macppc seems to need a couple more casts before it will compile a
kernel after the cardbus rectification.

ok jsg@


# 1.71 22-Mar-2010 jsg

Remove some cardbus defines and types which are identical to
their pci counterparts, similar to recent changes in NetBSD.

ok oga@ deraadt@ jasper@


Revision tags: OPENBSD_4_7_BASE
# 1.70 13-Jan-2010 jsg

As per NetBSD move HAYAKAWA Koichi's licenses to two clause.


# 1.69 11-Jan-2010 kettenis

When mapping CarBus memory BARs, enforce a minimum alignment of 0x1000. This
is the granularity of the windows provided by the CardBus bridge. A smaller
alignment may result in those windows covering address space used by other
PCI devices in the machines. Fixes CardBus xl(4) n naddy's X40.


# 1.68 28-Aug-2009 kettenis

Writing 0 to the PCI_LEGACY register *is* the proper way to disable the
legacy register mapping. So remove comments and #ifdef 0'ed code that
questions this.

ok miod@


# 1.67 25-Jul-2009 kettenis

Stop using rbus to set up the socket BAR if it has been left unitialized
by the firmware; our PCI code takes care of this now. Also eliminate
support for I/O socket BARs. There is no evidence they actually exist.
Clean up some unused structure members while there.

ok miod@


# 1.66 21-Jul-2009 miod

Use the symbolic constants for the window registers in pci configuration
space in pccbb_winset(), instead of their bare values. Saves time for grep
users. While there, a few grammar and typo fixes in comments.


# 1.65 20-Jul-2009 miod

Pass a pci_chipset_tag_t to pci_intr_line(), to eventually allow the
logic to be chipset dependent; no functional change yet.
ok kettenis@


Revision tags: OPENBSD_4_6_BASE
# 1.64 03-Jun-2009 jsg

ansi function decls, no binary change.


Revision tags: OPENBSD_4_5_BASE
# 1.63 15-Oct-2008 blambert

Second pass of simple timeout_add -> timeout_add_sec conversions
This should take care of the simpler ones (i.e., timeout values of
integer multiples of hz).

ok krw@, art@


# 1.62 25-Sep-2008 chl

remove dead store.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_4_4_BASE
# 1.61 20-Jul-2008 kettenis

On TI cardbus bridges, enable PCI interrupt routing if the device has not
been initialized by the firmware. This was probably the intention of the
origional code, however, it used the wrong default value for the register
in question.

Add TI PCI1510 to the list of 12XX-compatible bridges.

"be brave" deraadt@


# 1.60 22-May-2008 mk

More timeout(9) usage cleaned up.

ok claudio


Revision tags: OPENBSD_4_3_BASE
# 1.59 20-Dec-2007 kettenis

Get rid of __HAVE_PCCBB_ATTACH_HOOK.


# 1.58 19-Dec-2007 kettenis

If the CardBus bus number is left unconfigured, only attach pcmcia(4).

ok jsing@, fgsch@


# 1.57 14-Dec-2007 kettenis

Revert previous commit; something is still wrong, and I can't figure out what
fast enough.


# 1.56 09-Dec-2007 kettenis

Un-#ifdef code, such that we don't attach cardbus if the bus nuber is
unconfigured.

Tested by a few; ok deraadt@ (a while back).


# 1.55 30-Nov-2007 deraadt

skip the bad mapping checks for now, sigh


# 1.54 30-Nov-2007 miod

Skip the sanity test introduced in r1.50 on TI devices, as it gets triggered
with valid devices.


# 1.53 26-Nov-2007 deraadt

correct newlines surrounding the sub-bus configuration, and unify
pchb's further
ok reyk oga


# 1.52 25-Nov-2007 deraadt

missing line from previous commit; return 1 for interrupts we do handle


# 1.51 25-Nov-2007 deraadt

Interrupt handlers which do nothing should return 0 (or -1 if they are not
sure)
ok kettenis jsg


# 1.50 25-Nov-2007 deraadt

If some rather important registers read as 0xffffffff then the device
is probably not there and we should not attach cardbus. Viao TZ-series
with a Ricoh cardbus+ofw+MMC/SD/MS/.. chip
ok kettenis jsg


# 1.49 25-Nov-2007 deraadt

remove an ugly nested block


# 1.48 23-Nov-2007 kettenis

Don't do anything in the shutdownhook if the registers aren't mapped.

ok deraadt@, fgsch@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.47 12-Oct-2006 grange

Add a symbolic name parameter to cardbus_intr_establish().
Count cardbus devices interrupts in cbb(4) using evcount(9).

ok deraadt@


Revision tags: OPENBSD_4_0_BASE
# 1.46 21-Jun-2006 fkr

removal of '#ifdef rbus ... #else ...' directives, we use rbus in all
cases anyways, so we might as well remove code (the !rbus case) thats been
dead throughout the last years and just use the rbus code without ifdefs.

brad, miod "I am all for this diff"
ok deraadt, mickey


# 1.45 14-Jun-2006 fkr

remove redundant commented debug define


# 1.44 02-Apr-2006 brad

- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.

From NetBSD


# 1.43 11-Mar-2006 brad

splvm.


# 1.42 11-Mar-2006 brad

remove splimp handler.


Revision tags: OPENBSD_3_9_BASE
# 1.41 26-Nov-2005 krw

Add some missing 'break;'s in auich and auixp that lint spotted. While
here, use FALLTHRU or FALLTHROUGH to make lint even happier.

ok marco@ miod@


# 1.40 23-Nov-2005 mickey

use proper bus_size_t for register offsets and not bus_addr_t; uwe@ miod@ testing


# 1.39 05-Oct-2005 tdeval

Support the CardBus part of TI's PCI7XX1 controllers.
ok deraadt@, miod@


# 1.38 02-Oct-2005 fgsch

add special handling for some o2micro devices, so by instance atheros works.
adapted from similar linux change by
Aristeu Sergio Rozanski Filho <aris at cathedrallabs dot org>
via Leonardo Chiquitto Filho <leonardo at iken dot com dot br>.
test compiled by pedro@.


# 1.37 16-Sep-2005 fgsch

spelling.


Revision tags: OPENBSD_3_8_BASE
# 1.36 03-Aug-2005 fgsch

enforce 10-bit width for i/o addresses when start address is assigned by
the driver and calcule address line mask when is not. from haya@netbsd.org.
tested by several ppl.


Revision tags: OPENBSD_3_7_BASE
# 1.35 27-Jan-2005 millert

Add pcmcia_intr_string() to format the intr string for pcmcia attach
routines.


Revision tags: OPENBSD_3_6_BASE
# 1.34 14-Jul-2004 mickey

tweaks for ti12xx bridges; from freebsd via rees@


Revision tags: OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B
# 1.33 23-Dec-2003 mickey

do not panic if there is no IPL_IMP


Revision tags: OPENBSD_3_4_BASE
# 1.32 25-Jun-2003 mickey

add topic97b support; from netbsd and tested by Pedro la Peu <pedro@am-gen.org>


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_A UBC_SYNC_B
# 1.31 23-Jul-2002 drahn

Cardbus/pcmcia support for macppc. parts borrowed from NetBSD, and other
portions of the tree.


Revision tags: OPENBSD_3_1_BASE
# 1.30 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.29 14-Mar-2002 millert

First round of __P removal in sys


# 1.28 30-Jan-2002 fgsch

TI 1410 PCI-CardBus support.


# 1.27 24-Dec-2001 mickey

fix a // comment and kill a few trailing spaces


Revision tags: OPENBSD_3_0_BASE UBC_BASE
# 1.26 25-Aug-2001 art

branches: 1.26.4;
Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.25 22-Aug-2001 aaron

Initialize auto variable (win[{0,1}].win_flags). Also, if PCCBB_MEM_CACHABLE
isn't set, clear the prefetchable bits in the bridge control register. These
fixes from NetBSD. Now OpenBSD won't hang when it tries to read the CIS from
an ADMtek-based card through a Ricoh-based PCI-CardBus bridge.


# 1.24 19-Aug-2001 mickey

fetch sc_intline from pci_intr_line(ih) to accomodate for
the line being possibly resolved in pci_intr_map().
found and tested by jason@


# 1.23 19-Aug-2001 miod

...and convert this one as well.


# 1.22 17-Aug-2001 deraadt

quieten pcmcia/cardbus interrupt handling at unsuspend time


# 1.21 20-Jun-2001 niklas

Comment spelling fix, and remove static regardless of
CBB_DEBUG setting


# 1.20 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.19 16-May-2001 ho

No need to check M_WAIT/M_WAITOK malloc return values. (art@ ok)


# 1.18 01-May-2001 mickey

branches: 1.18.2;
restore socket base addr and bus number on resume; from netbsd


Revision tags: OPENBSD_2_9_BASE
# 1.17 01-Feb-2001 aaron

Do not attempt to attach cards that have unsupported (i.e., non-5, non-3)
voltages. Fixes the problem with those silly SCM Microsystems PCI-CardBus
dock boards that are often shipped with Lucent WaveLAN cards. Thanks to
drahn@openbsd.org for testing and dave@arbor.net for originally reporting
the problem.


# 1.16 27-Jan-2001 mickey

introduce and use a flag indicating that interrupts are
enabled for this cbb. essentially this means that cbb
driver has completed it's initialization and is
ready to treat interrupts. this was exposed by
ccb's sharing their interrupt and pccbbintr() being called
for cbb which has not completed attachment due
to interrupt sharing.


# 1.15 22-Jan-2001 deraadt

repair printing


# 1.14 21-Jan-2001 mickey

map and establish interrupt earlier in the attach routine,
instead of middle of the thread. behaviour remains the same.
since interrupts are disabled in the controller until proper
time this is safe to do this way.
deraadt@ ok


# 1.13 06-Dec-2000 aaron

BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.

From NetBSD.


# 1.12 29-Nov-2000 aaron

Bugfix: reset 16-bit pcmcia in chip initialisation sequence; from NetBSD.


# 1.11 29-Nov-2000 aaron

Correct PCI interrupt setup routine for Texas Instruments PCI113X CardBus
bridges so that hot insertion and removal works; from NetBSD.


# 1.10 29-Nov-2000 aaron

Clarify that the RX5C57X requires write to the PCI_LEGACY to disable and
not PCI_BCR_INTR; from NetBSD.


# 1.9 29-Nov-2000 aaron

Power down PC cards at shutdown time; from NetBSD. I'm also reverting my own
fix for this (rev 1.7) as this is the better way to do it. This fixes the
problem seen with reboot while an xl(4) CardBus card is in a slot on my Toshiba
Tecra 550CDT (so it should fix the same problem espie@ has seen on a different
model Toshiba laptop).


Revision tags: OPENBSD_2_8_BASE
# 1.8 09-Oct-2000 aaron

Defer most of the attach process as recommended in the comments; mickey@ ok


# 1.7 24-Sep-2000 aaron

For the Toshiba TOPIC95B CardBus controller, we must clear the socket and slot
control registers at shutdown else we hang. Fixes it on my laptop, should help
out espie@ on his Toshiba system too.


# 1.6 25-Jul-2000 mickey

convert to new timeouts


# 1.5 06-Jul-2000 aaron

Sync with NetBSD.


# 1.4 06-Jul-2000 aaron

Reorder irq enabling and vector setup; makes Ricoh-based PCI-CardBus bridges
behave more nicely. Also remove statics. From niklas@


Revision tags: OPENBSD_2_7_BASE
# 1.3 26-Apr-2000 aaron

Remove one of my completely incomprehensible debugging printf's.


# 1.2 20-Apr-2000 aaron

Fix function prototype so it compiles again.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.