Commit Graph

204 Commits

Author SHA1 Message Date
drochner d8e1a7b61a Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
2012-01-30 19:41:18 +00:00
drochner 1ca3ef385b remove some bloat:
-cardbus doesn't use multiple interrupt lines like PCI, and it doesn't
 use machanisms like interrupt line register and swizzling -- no need
 to carry around dummy information, this is all dealt with by the
 bridge
 (I'm asking myself how "rbus_ppb" can work -- a bridge attached to
 cardbus just can't work like a normal PCI bridge as far as interrupts
 are concerned. I thing that should be a hardware specific driver
 because behavior is not covered by a standard.)
-cardbus always uses 3.3V -- no need for a variable to keep track
 of the voltage
2011-08-01 11:20:26 +00:00
dyoung ad398c30df Don't set the iobase and iosize members of pcmciabus_attach_args because
they're not used in any meaningful way.
2011-07-26 22:21:02 +00:00
jruoho 9844967b1c Stop using aprint_debug(9) in an interrupt handler. 2011-01-04 10:40:17 +00:00
phx 709cd38f1c Add TI PCI1510.
Enable TI12XX PCI interrupt in MFUNC when MFUNC pin0 and pin1 are zero.
Ignore the other pins, which may be non-zero (e.g. IRQSER in pin3).
2010-12-27 19:02:32 +00:00
dyoung 0c6d62cfe9 Change sc_pil_intr_enable from an int to a bool. No functional change
intended.
2010-04-20 23:39:10 +00:00
dyoung ad6e139a80 Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9).  Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's.  Tested on i386 and on sparc64.
2010-04-19 18:24:26 +00:00
dyoung 9109db5aef rbus is always #defined as 1, so unifdef -D rbus=1. 2010-03-15 20:02:55 +00:00
dyoung 4ce33933f8 Cardbus_free_tag() and cardbus_free_tag() are no-ops, so get rid of them
to simplify the code a bit.
2010-02-25 00:47:39 +00:00
dyoung 7c4be3328d Start to tuck Cardbus under the PCI abstraction. Step #1, textual
substitution: for all practical purposes, pcitag_t and cardbustag_t are
interchangeable, so just use pcitag_t.  Ditto pcireg_t and cardbusreg_t.

Poison new uses of cardbusreg_t and cardbustag_t by deleting the type
definitions.
2010-02-24 23:38:40 +00:00
dyoung c1b390d493 A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
2010-02-24 22:37:54 +00:00
dyoung cd6e1fbf91 Expand PMF_FN_* macros. 2010-01-08 19:53:10 +00:00
snj be360188fc Move to 2-clause license. Approved by HAYAKAWA Koichi (copyright holder). 2009-12-15 22:17:12 +00:00
blymn 2a02a6feb9 Destroy mutex and condvar initialised in pccbbattach(). 2009-08-07 12:09:50 +00:00
blymn c6b1721d19 Clean up extraneous white space. 2009-08-07 12:04:43 +00:00
dyoung 487ea78a9c Use kpause(9), cv_timedwait(9), and cv_signal(9) instead of tsleep(9)
and wakeup(9).

Use mstohz(9).

XXX Protection against spurious wakeups is still needed, but this patch
XXX makes the code no worse than before in this regard.
2009-07-23 21:22:25 +00:00
dyoung a0d0f249f9 Let us detach pcmcia0 and cardbus0 at cardslot0, and cardslot0 at
cardbus0.
2009-05-21 17:32:32 +00:00
cegger 59717d7121 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-06 09:25:14 +00:00
dyoung 85d5fd7b83 In pccbb_pci_callback(), set CBB_SPECMAPPED in sc_flags if we've
acquired bus space from bus_space_alloc(9) or from rbus_space_alloc(),
so that we use the appropriate routine to release the bus space in
pccbbdetach().  This stops panics during cbb(4) detachment (esp. at
shutdown) on some systems.

Thanks to Kurt Schreiner for testing the fix, Kurt, Patrick Welche,
Pouya D. Tafti, and Matt Green for reporting.
2009-05-03 00:31:12 +00:00
dyoung 0d1ba3e899 During shutdown, detach devices in an orderly fashion.
Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks.  For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown.  Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags.  Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag.  The default for kern.detachall is 0.  SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress.  In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs.  Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
2009-04-02 00:09:32 +00:00
msaitoh f9ccf64b65 Fix typo(s/interupt/interrupt/) 2009-03-05 01:38:12 +00:00
bouyer e83cf7c074 Fix bus_addr_t/bus_size_t confusion 2009-02-13 22:39:37 +00:00
dyoung e7aed4b441 When the power status changes, always note the change and wake the
socket events thread.  Sometimes we would not note the power-status
change if the socket also indicated a change in card status.
2009-02-06 01:15:53 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
christos 56c00d466d another TI bridge. 2008-10-25 18:46:38 +00:00
dyoung 2b1e3ce6be Identify the O2 Micro OZ711E0 and treat it the same as all of the
other O2 Micro bridges, which seem to spuriously report bus errors
if parity-error detection is enabled.
2008-08-06 15:50:46 +00:00
drochner 81ae74c4eb On cardbus configuration reads, check for a master abort in the cbb
and return all-ones explicitely.
Since pccbb.c rev. 1.151 the cbb is set to translate cardbus master
aborts which makes that the PCI configuration read on the primary bus
returns random junk. This can cause the probing code to get confused.
The issue was reported by KIYOHARA Takashi and Jonathan A. Kollasch,
the patch was tested by KIYOHARA Takashi.
2008-07-03 13:37:34 +00:00
drochner ef7fd726d9 delete more dead code, remove use of pcic_handle except of some local
uses in pcmcia ressource management which is copied from ISA pcic,
so use our softc as handle exported to generic pcmcia code and kill
the ph_parent backpointer - this makes the code simpler and smaller
2008-06-26 20:57:10 +00:00
drochner c1194a4601 remove some more dead code, and use the softc as handle in more internal
functions rather than pcic_handle
2008-06-26 18:05:48 +00:00
drochner ed1bea6b56 remove references to nonexisting members of pcic_handle in commented out
and debug code, from Patrick Welche
(we could as well drop pcic_handle completely and use our softc as
the opaque handle for the pcmcia code - this would simplify the code
even more)
2008-06-26 17:22:23 +00:00
drochner cc29fcf8b9 constify the pcmcia/cardbus method tables 2008-06-26 12:33:17 +00:00
drochner 2b26f69613 Avoid the use of i82365var.h - we don't use any functions from there.
Extract some data structures for ressource management into our private
header instead. This allows to use a typed pointer instead of a
generic one which saves a lot of typecasts.
Also remove something marked as "dirty hack" which I admittedly don't
understand, but it doesn't look useful...
2008-06-25 15:29:23 +00:00
drochner dbc8757839 split device/softc for pccbb, the cardbus half of cardslot and cardbus
(not yet pcmcia, there is a lot of md code involved)
2008-06-25 11:42:32 +00:00
drochner 36b6bc746c clean up the cardbus interrupt stuff:
There were cardbus_intr_line_t and cardbus_intr_handle_t used intermixed
for the same variable, and that variable is pretty much useless because
cardbus doesn't follow the PCI interrupt swizzling etc scheme.
Useless interrupt numbers were printed on cardbus device attach.
So as a first step to sanity, kill cardbus_intr_handle_t and poison
cardbus_intr_line_t to discourage printing it as a %d.
Use cardbus_intr_line_t consistently throughout the code.
Remove the "interrupting at foo" messages because the information
is misleading. We could come up with a better interrupt vector
information, but because cardbus interrupts are mediated by pccbb
it would still be misleading.
2008-06-24 19:44:51 +00:00
drochner 52b8fec3cf clean up some useless code and variables in cardbus attachment 2008-06-24 17:32:09 +00:00
dyoung ea0d0ed51e Distinguish O2 Micro bridges from generic bridges. PCI Parity
Error reporting seems to be broken on O2 Micro bridges, so do not
activate it.  Should fix kern/38698, reported by Andreas Gustafsson.
2008-05-27 21:32:47 +00:00
dyoung eef522873b Use __arraycount(). 2008-05-22 01:22:17 +00:00
dyoung 11e3712cc6 Check device_has_power() instead of device_is_active() in pccbbintr(),
since the driver must acknowledge some interrupts while it leaves
the suspended state.  This protects against an interrupt storm that
will hang the system while I resume rtw0 at cardbus1.
2008-03-04 22:15:16 +00:00
dyoung f580a3a869 Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:13:39 +00:00
dyoung 46be8b643f Fix a two races between the initialization code and cbb(4) interrupts:
establish the interrupt handler before enabling interrupts, so that
we will not get an interrupt storm that keeps the system from making
any progress.  (We may have only been susceptible to the storm if
cbb(4) shared an interrupt with, say, uhci(4)).  Also, finish
setting up the pcic_handle before enabling interrupts, so that the
Pcic_read() call in pccbbintr() will not jump to address 0!

Now, pccbb_intrinit() encapsulates all of the interrupt initialization.

Explicitly enable card-status changed (CSTSCHG) events.

Paranoia: ensure that writes to the socket event register (interrupt
acknowledgements) are flushed to the h/w by reading the register
(gross).  We really need something like
bus_space_sync(BUS_SPACE_BARRIER_WRITE_BEFORE_INTERRUPT).

More paranoia: in pccbbintr(), if the device is inactive, get out.
2008-02-02 00:31:25 +00:00
dyoung b31e1f190c Use aprint_*_dev() and device_xname() instead of accessing dv_xname
directly.
2008-02-01 21:13:44 +00:00
christos 9d6619f2e6 Remove ricoh hack; FreeBSD does not seem to do it, and it was a remnant from
the branch. Things should work properly now.
2008-01-15 21:55:24 +00:00
dyoung b6c0385fe0 Use device_t, device_private(). 2008-01-14 06:12:13 +00:00
dyoung 132fca675f In pccbbdetach(), panic if interrupt handlers are still registered
after detaching children.

Use PCI_CB_MEMBASE0, PCI_CB_MEMLIMIT0, PCI_CB_IOBASE0, PCI_CB_IOLIMIT0
instead of magic numbers.
2008-01-14 03:01:41 +00:00
dyoung e9596bf19e Introduce a struct cardbus_chipset_tag, and make cardbus_chipset_tag_t
a pointer to that struct, so that we cannot assign pointers of
arbitrary type to cardbus_chipset_tag_t.  Tweak cbb(4) to accomodate
this change.

Make Cardbus_conf_read() and Carbus_conf_write() pass the right
arguments to cardbus_functions->cardbus_conf_{read,write}() for a
change.

Let's hope this stops the crash in cardbus_function_enable() that
macallan@ reported to me.
2008-01-02 23:11:34 +00:00
dyoung 9f5c1f09f7 Use LIST_FOREACH(). 2007-12-20 20:48:24 +00:00
dyoung cf784f4497 Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
        elansc0 at pci0
                gpio0 at elansc0
        cbb0 at pci0
                cardslot0 at cbb0
                        cardbus0 at cardslot0
                        pcmcia0 at cardslot0
        cbb1 at pci0
                cardslot1 at cbb1
                        cardbus1 at cardslot1
                                rtw0 at cardbus1
                        pcmcia1 at cardslot1
        sip0 at pci0
                nsphyter0 at sip0
        sip1 at pci0
                nsphyter1 at sip1

Whew!
2007-12-16 21:28:30 +00:00
martin 6cdfaa0c8f As a stopgap fix: disable a pci_conf_ access at offset 0x82 on archs
that would mind ;-) IMHO this access violates the PCI spec, so this
should be solved differently.
2007-12-11 11:11:22 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
jmcneill 4fbe23fdd0 aprintify 2007-12-01 04:50:50 +00:00