Commit Graph

176 Commits

Author SHA1 Message Date
Warner Losh
253b72896c Parens considered good. 2002-09-29 23:36:17 +00:00
Warner Losh
9f977fb187 Add support for writing to mapping high memory for pccard memory
windows.  Right now we only support pci chips that are memory mapped.
These are the most common bridges in use today and will help a large
majority of the users.

I/O mapped PCI chips support this functionality in a different way, as
do some of the ISA bridges (but only when mounted on a motherboard).
These chips are not supported by this change.
2002-07-20 22:29:23 +00:00
Warner Losh
1aa3e5415e Integrate the hw.pcic.pd6722_vsense tunable from the nomads list.
This allows one to select the method of 3.3V card detection from the
three possible choices (none (0), the "6710 way" (1) and the "6729
way" (2)).  The default is the 6710 way, since it works in the most
cases.  The datasheets for the 6722 suggest that the '29 way is more
correct, but experience has shown this method to cause some laptops to
hang solid.  See source code for details until I update the man page.

Submitted by: shibata-san (chiharu shibata <chi@bd.mbn.or.jp>)
2002-07-18 08:13:45 +00:00
Warner Losh
d9619df632 o Remove workaround that I put in to mask the BadVcc problem.
o Add preliminary support for Cirrus Logic CL-PD6729 using PCI
  interrupts.  To use it you you need to set hw.pcic.pd6729_intr_path
  to 2.  This is allow us to still default to ISA intrrupt path for
  this part (which is found much more often in laptops using ISA IRQs).
  But some PCI cards have this part on them and this should allow them
  to be used.  It is untested on PCI, but it seems to not break the ISA
  case.
o Better sysctl descriptions (I hope).
2002-07-17 06:02:07 +00:00
Giorgos Keramidas
bab6337218 Typo: do do -> to do.
Reviewed by:	imp
2002-07-14 02:25:21 +00:00
Warner Losh
1d88dfe265 What:
o ToPIC is happy with two cards now, even when the two cards are
	  modems.
	o Fix (all?) hangs on boot when power is applied to the card.  I
	  suspect that this will make the Ricoh bridges happier and also
	  make a lot of VAIO owners happy (confirm to me in private email
	  please :-).
	o All Cardbus bridges should now support 3.3V, X.XV and Y.YV cards,
	  to the extent that the underlying hardware supports such cards.
	  (X.X and Y.Y haven't been assigned values yet :-).
	o Better 3.3V support for Ricoh ISA bridges.

How:
	o Don't mess with the power register when scanning the cards.  It
	  is unnecessary and causes BADVcc conditions on many chipsets.  These
	  in turn can cause an interrupt storm.
	o Make pcic_disable reset the slot's voltage.
	o Move initializing voltage for the slot until after it has been
	  disabled.
	o Fix a lot of issues with the pcic_cardbus_power routine.  We
	  now properly enable the card and take it out of reset after
	  a power change.
	o When detecting the card's voltage, if we're in a BadVcc state,
	  direct the bridge to rescan the card for what it supports.
	  (we might need to in the future set the power register to 0
	   before doing this).
	o Don't preserve CLKSTOP.  need to revisit this.
	o Better support for Ricoh ISA bridges for 3.3V cards.
	o Don't write to PCIC_POWER directly as offten, but instead go
	  through the pcic_power interface.
	o All cardbus bridges now default to use cardbus power control.
	o Add misc register definitions.
	o remove some (now) bogus comments.

Extra Special Thanks To: Scott Lamber for his kind and generous loan
of a Toshiba laptop with a ToPIC 100 in it for my use.
2002-06-23 01:55:10 +00:00
Warner Losh
91f60fd74f Better power code and better power diagnostics 2002-03-20 19:02:08 +00:00
Warner Losh
296596145c The datasheet for the 6710/6722 says that you must use one method to
detect 3.3V cards for the 6710 and another method for the 6722.  This
latter method is also how the 6729/6730 is supposed to detect 3.3V
cards.  This method works great on my Fujitsu Stylistic 500.  Sadly,
it appears that not all laptop makers are as detail oriented as the
folks that made the Stylistic.  IBM Thinkpad 701C and AST Asentia 810N
both hang hard when the 6729 method is used, but at least the thinkpad
works when the 6710 method is used.  The failure mode appears to be any
access to the memory that we've mapped the CIS in causes the machine to
hang until you eject the card.  The Thinkpad, at least, works with this
change, and it doesn't break my Stylistic.

MFC after: 4 days
2002-01-14 14:10:13 +00:00
Warner Losh
99b8465544 Introduce the concept of "default" voltage. Have pccard layer use this
value (-1) in lue of 50 (which assumes a 5.0V card).  The rest of the
pccard system doesn't detect the proper voltage for the card, so we have
to do it on powerup.  Many (all?) 3.3V cards can tolerate 5.0V for reading
the CIS, but may fail to operate properly when so powered.

Idea from: Chiharu Shibata-san <chi@bd.mbn.or.jp> in bsd-nomads:15867
2001-11-11 06:58:43 +00:00
Warner Losh
93da209126 o Try to do 3.3V support better for the 6722 and 6729/30.
o Bite the bullet and create controller types for the 6729 and also for
  the 673x.  Rename the 672x to 6722.
o Define minimal extended register info (just register 0xa for reading VS[12]).

# I think the last version may have broken 673x controllers, but this should
# fix them.

Tested on the 6722, but not the 6729.

Ideas from: Chiharu Shibata-san's article in bsd-nomads:15866
2001-11-09 07:33:54 +00:00
Warner Losh
3761b249c9 Fix the 3.3V support for Cirrus Logic CL-PD6710. This appears to work
on my CL-PD6722, but won't work on the CL-PD6729.  The latter two need
more sophisticated detection of 3.3V cards than I'm up to at the
moment.  Also, only a few of the ISA chipsets that support 3.3V will
likely work at the moment.

It appears that for 3.3V cards we must detect them and adjust the
pwr.vcc value from 50 to 33.  Give a strong hint to automatically
power up the card for PD_POWER cards.

This makes my SMC 2602W (the 3.3V version of the 2632W) work on my
Fujitsu Stylistic 500.

SMC 3.3V card donated by: Ryan Losh
Thanks to: bsd-nomads for reviews of past 3.3V code
2001-11-09 06:26:57 +00:00
Warner Losh
516fdf9478 Add a tunable (hw.pcic.boot_deactivated) which will boot the system
with the pccards deactivated.  This can work around some problems in
pccard system, but is also for people that want to explicitly turn on
cards after boot rather that at boot.

MFC after: 7 days
Submitted by: iwasaki-san
Reviewed by: ume-san, shiba-san
2001-10-23 07:04:03 +00:00
Warner Losh
7cf44afd1a <jkh> "Hey Rocky, watch me eject this pccard outta my laptop!" "What,
again?  That NEVER works!"  "This time for sure!"

Minor overhaul of how we do interrupts for the pci interrupt routing
case to cope with card ejection better (read: make it not hand on so
many cards):
	o Reintroduce func_intr and func_arg and use the to store the
	  interrupt handler to call.
	o Create a pcic_pci_func_intr to call the real interrupt handler
	  iff the card hasn't been ejected.
	o Remove some checks in pcic_setup_intr now that it is used
	  exclusively for isa routed interrupts.
	o Defer the eject event until later too, but make sure we can't
	  do any client driver ISR calling in the interrum.
	o Add some simple code to make sure that we don't attach more
	  than one child.  This should fix pccardd starting twice
	  problem (ala single user -> multi-user when you started pccardd
	  by hand in SU).

MFC: after jkh thinks I've put the crack pipe away.
2001-09-13 08:26:55 +00:00
Warner Losh
5f34898eb2 MFS: put debug writes behind boot verbose. 2001-09-04 20:08:33 +00:00
Warner Losh
592823383b Move to using a chip function + function pointers to deal with the
function and csc interrupt routing path (eg, ISA or PCI) so that we
can more easily switch between the two.

When we don't have a card ISR, put the function interrupt into ISA
mode.  This effectively masks the interrupt since it happens once, and
not again until we have an ISR.  This should help hangs, and might
help people that unwisely update the kernel w/o updating pccardd.
This is done at mapirq time.

Force CL-PD6729/30 to use ISA interrupt routing and maybe even detect
the number of pccard slots properly (this is still WIP).  We aren't
going to support PCI interrupts for this release.  A future release
should support them, however.  Shibata-san's 3.3V fixes are not
included.

Add a hack which should, in i386, rewrite IRQ 0 cardbus bridges to be
IRQ 255, which should cause interrupts to be routed.  This is mostly
untested since my one tester disappeared after reporting nothing
changed.

Implement, but do not use, a power method called cardbus.  It looked
like a great way to get around the 3.3V problem, but it seems that you
can only use it to power cardbus cards (I get no CIS when I enable it,
so maybe we're programming things bogusly).

GC the intr and argp stuff from the slot database.

Improve the ToPIC support with the power hacks that Nakagawa-san
published in FreeBSD Press and that Hiroyuki Aizu-san ported to
-stable.  The ToPIC hacks were for 3.3V support in ToPIC 100, but it
looks like the '97 also has identical registers, so use them too.

Add some #defines for the cardbus power stuff.

Finally implement making CSC on the Ricoh chips ISA or PCI.  This will
allow polling mode to work on vaios, I think.

Add some minor debugging.  This should likely be cleaned up or put
behing a bootverbose.

Some of this work, and earlier work, was influanced by Chiharu
Shibata-san's power handing patches posted to bsd-nomads:15866.

MFC: Soon, if possible.
2001-09-04 04:47:58 +00:00
Warner Losh
c98c9548b1 The tunable is hw.pcic.irq, but the hw.pcic.override_irq was how it was
reported in sysctl.
2001-08-25 22:39:44 +00:00
Warner Losh
0f102020db Rearrange how we do interrupt routing tweaking. We now have
hw.pcic.intr_path	{1,2}	1 == ISA, 2 == PCI
	hw.pcic.init_route	Force TI chipset initializations in edge case.
2001-08-21 20:04:42 +00:00
Warner Losh
dc2e861bdb Merge from stable (which seems to have been spammed at some point in current):
#ifdef the deltap pcic_set_memory_offset argument so that raylink
driver works.
2001-08-14 23:34:09 +00:00
Warner Losh
cc3a07dbb3 Minor style(9) nits to make code more readable 2001-08-14 23:16:01 +00:00
Warner Losh
482a667634 Treat min,max of 0,0 for IRQ special. Reject it if we didn't specifically
assing an IRQ.  Add better comments while I'm here.

MFC after: 1 day
# Note: That's merging all the -current pci pcic code, not just this one
# change for the Aug 15th code freeze.
2001-08-14 19:23:12 +00:00
Warner Losh
043b27b450 Move ISA interrupt ISR and timeout routines to pcic from pcic_isa so
that we can use them in the pci code when we have to fall back to ISA
interrupt routing.
2001-08-10 06:07:20 +00:00
Warner Losh
0d3576d9bc Now that we are setting a bit in the PCIC_INT_GEN (0x3) register, we
can't blindly write zero into it to disable the card.  We must
preserve this bit.  This changes pcic_disable to only clear the bits
we know we need to clear on card disable, thus preserving the magic
bit for many TI bridges.

This appears to have fixed the problems that people are reporting
about the system failing to recognize cards being inserted or removed
(or both).  Greg: This may fix your problem too :-).
2001-08-05 07:02:42 +00:00
Warner Losh
53af1c8a3d TI cardbus bridges, 12xx and newer, have an interesting register. It
is the diagnostics register at offset 0x93.  When bit 5 is set in this
register, bits 4-7 in ExCA register 0x5 being 0000 are required for
pci interrupt routing.  When it is clear, then bit 4 of ExCA register
0x3 is used to enable it.

The only other issue is that when you route interrupts this way, you
must read ExCA register 0x4 in order to clear the interrupt, else you
get an interrupt storm.

Deal with this requirement by setting things up.  It is believed that
this won't hurt other chipsets, but other chipsets may require their
own work arounds.
2001-08-01 19:41:56 +00:00
Warner Losh
372458622f A bunch of interrupt related cleanup.
o Move PIOCSRESOURCE from pccard to pcic so the kernel can give pccardd
  better hints as to what resources to use.
o Implement an undocumented hw.pcic.interrupt_route to allow people that
  need to do so to route their interrupts in a non-standard way.
o Only preallocate a resource in probe if we're routing via pci.
o If we aren't routing via pci, then set the irq to use explicitly
  to defeat the automatic IRQ routing of the pci layer.

This, with the pccardd code should be close to what can be committed
to -stable.
2001-07-31 06:44:37 +00:00
Warner Losh
4ee0b26518 Move pcic_override_irq from pcic_isa, to pcic. 2001-07-31 06:32:02 +00:00
Warner Losh
29edba568b It is spelled INTR_FAST in current and INTR_TYPE_FAST in stable, so try to
make allowances.
2001-07-28 04:08:25 +00:00
Warner Losh
9d0ea05213 Stable requires machine/clock.h to quiet warnings. It isn't
strictly necessary on current, but having it in here makes the diffs with
stable smaller and doesn't hurt anything except for phk's redundant include
finder.
2001-07-28 04:04:05 +00:00
Warner Losh
d13600a5af Introduce two new tunables from the boot loader.
hw.pcic.irq		Globally set the IRQ for all pcic devices' management
			interrupt (aka card status change or CSC interrupt)
			This is what used to be known as
			machdep.pccard.pcic_irq (which has been retained for
			now for compatibility).
hw.pcic.ignore_fuction_1 Ignores function 1 for all PCIC bridges by not
			attaching to them.  Lucent released a huge batch
			of cards that were imporperly manufactuered (lacking
			the 0 ohm resister to disable slot 1).  This is
			a big hammer to keep those cards from causing problems
			(I've had 4 people contact me saying my patches
			worked great once they added a kludge to always ignore
			function 1, or until they soldered these resistors
			in place!).

No clue where to document these.  They act as both boot loader environment
variables, as well as read-only sysctls after boot.

At the same time, sort sys/systm.h in its proper order after sys/sysctl.h.
2001-07-27 16:07:02 +00:00
Warner Losh
ebea20aed7 Minor nits merged from my stable tree:
o kill blank line that I introduced in cardinfo.h
o Delete unused variable wasinactive.
o return 0 from pccard_resume.
o Set the state and lastsate initially to be empty.
o move comment above code for interrupt dispatching.
o Powerstate interface is now available as of 430002, not 500000 (note that
  this change will be not 100% correct since the power state stuff didn't
  enter current until well after 500000, but it is good enough for the two
  branche we have going now).
2001-07-27 07:47:35 +00:00
Warner Losh
c1c1a23f53 Attempt to fix and document interactions between suspend/resume and pccardc
power x 0.

pccardc power x 0 used to disable the slot.  But a suspend/resume
would reactivate the pccard.  It no longer does that.  Now the
disabling of the slot is sticy until it is reset with power x 1 or the
card is ejected.  This seems closer to correct behavior to me.

o Process all card state changes the same using pccard_do_stat_change().
o Cleanup disabling the card so that we can preserve the state after
  the change.  Basically, don't set it to empty as often as we do.
o On suspend, the new state is "empty" and the laststate is "suspend"
o Document state machine with a diagram of states and edges.  The
  edges are labeld to tell the reader what event causes the external
  state changes.
o "machdep.pccard.pcic_resume_reset" may be obsolete now.  We always
  call the bridge driver's resume method on resume now.  Otherwise cards
  won't automatically show up.  If it needs to stay, I'll add it back.
2001-07-27 07:21:42 +00:00
Warner Losh
e598f66151 Check the state of the slot when we resume. Set it to empty if we no
longer have a pccard in the slot.  This fixes the problem where pccard
would say that a card had been inserted on resume.  This also appears
to make the insert/remove events more reliable after a resume as well,
but that may be a different bug I need to hunt down.
2001-07-26 23:23:36 +00:00
Warner Losh
c799054841 Clarify some of the 3.3V code with better comments. Also, since the
types are treated as a bitfield, test them as such.
2001-07-01 23:40:54 +00:00
Warner Losh
8ffbd9cfc5 Add comments explaining why we do the somewhat odd irq mapping on PC98
machines with C-BUS cards.
2001-07-01 23:40:41 +00:00
Warner Losh
f5d80c4a5f Minor whitespace nit. 2001-07-01 23:40:19 +00:00
Warner Losh
9ae6dc2e12 Work around a bug in the current interrupt system by explicitly
rejecting INTR_FAST interrupts.  Since they can't be shared anyway,
this just short circuits a failure case that should work but is panic
fodder now.

This bug is that if the interrut condiation is active when you activate
the interrupt, then the interrupt routine will be called.  jhb had
a patch that may or may not work to fix it, but I've lost it.

This may be due to the sio probe doing something odd too.
2001-06-25 04:13:54 +00:00
Warner Losh
7077bc34aa Save the IRQ that we get in pci attachment.
Print type of pci bridge we find.
Force the IRQ of pci bridges upon all its children.
Allocate the resources on behalf of the bridge when we're testing to see if
they exist.

This should help people who don't read updating instructions very well.

This patch started out with an idea from Shigeru Yamamoto-san in -current.
2001-06-16 06:33:01 +00:00
Warner Losh
11cedf79a8 On PC-98, map IRQ 6 to IRQ 7 at the pcic level. That is, when we're
told to use IRQ 6, progam the pcic to use irq 7 instead.  Evidentally,
at least some of the cards are wired this way.  If you want to use irq
6, configure it.  All the mapping is done just before we set the
interrupt registers.  See [FreeBSD98-testers 5064] for details.

Added commentary about valid interrupts on some CBUS pc98 CL PD6722
based cards.

Submitted by: Hiroshi TSUKADA-san <hiroshi@kiwi.ne.jp>
2001-06-16 06:18:16 +00:00
Warner Losh
94b197e96d Move the pcic interrupt from pcic.c to pcic_isa.c. The ISA handling
for card change interrupts is different than the pci stuff that's
coming soon.  Set the management irq in different ways.  If
pci_parallel interrutp routing, then use the PCI way of getting
interrupts.  Move polling mode into pcic_isa since when we're routing
via pci polling doesn't work because many bridges (systems hang solid).

If we're routing interrupts via pci, they can be shared, so flag them
as such.

Note, this doesn't actually change anything since the pci attachment
isn't quite ready to be committed.
2001-06-04 03:29:06 +00:00
Warner Losh
f83a4e8171 Turns out that one bit isn't enough. Introduce two new fields
csc_route and func_route to hold the way that each interrupt is
routed.  csc is Card Status Change in the datasheets and standard, but
is called "Management Interrupt" in FreeBSDese.  There are three types
of interrupt routing:  ISA parallel, PCI parallel and ISA serial (some
chipsets support other types as well, but I don't plan on supporting
them).

When we try to allocate an interrupt, and the type for that interrupt
is pci_parallel, allow it to be shared by oring in RF_SHAREABLE to the
flags argument.  Introduce pcic_alloc_resource to allow this to
happen.
2001-05-28 02:53:02 +00:00
Warner Losh
92d08a4dcf Allow a shareable interrupts. Note, the bridge must set this flag or
the irq will be unshareable, as things are now.

More work likely is needed, but this is a good checkpoint.

# pcic_pci.c is getting closer :-)
2001-05-27 05:53:37 +00:00
Warner Losh
995823e999 Migrate from unit based to dev base. Don't save unit number, but do save
dev.  Convert all uses of unit to dev as appropriate.  Minor comment fixes
to pcic_softc definition.
2001-05-25 18:28:49 +00:00
Warner Losh
f7d83eb183 Add intrack field to each slot. This can be used to acknowledge
interrupts on other buses.  Right now it isn't used, but will be for
the pci attachment.

# Add copyright by me for this year since I've changed so much.
2001-05-25 05:25:43 +00:00
Warner Losh
5da1cb2e2f Minor name space issues. 2001-05-25 05:22:00 +00:00
Warner Losh
8cad38176d Use bus_space functions rather than inb/outb.
Add defines for PCIC_INDEX and PCIC_DATA offsets.
Change PCIC_INDEX_0 to PCIC_PORT_0
Add define for PCIC_NPORT.
Document why the vadem probe works.
2001-05-24 06:54:48 +00:00
Warner Losh
99efcc2bb9 Move getb1 and putb1 from pcic_isa.c to pcic.c. Rename them to
pcic_{get,put}b_io.  There are some pci bridges (the CL-PD6729 and
maybe others) that do not have memory mapped registers, so we'll need
these in both places.  Declare them in pcicvar.h.
2001-05-24 04:03:28 +00:00
Warner Losh
a8ed536b94 Add better support for the Ricoh 5C296 and 5C396 chips. These chips
have a slightly different 3.3V support than the other clones, so
compensate as best we can.  Note: 3.3V support is untested since I do
not have any 3.3V cards that I know of to test it with.
2001-05-23 05:06:04 +00:00
Warner Losh
13ab4e6dc1 Move allocation of ExCA registers from the base driver into the bus
attachment code.
2001-05-21 07:32:46 +00:00
Warner Losh
2003c3f530 Move setting of Vcc bit to before the vcc switch statement. The
datasheets I have seem to indicate that generally this bit is viewed
as a toggle.  Correct comments to match code.
2001-05-21 05:49:15 +00:00
Warner Losh
57462c010c Next step on the road to pci: power taming.
Work through the various power commands and convert them from a "is
this a foo controller or a foo' controller or a foo''' controller" to
a cabability based scheme.  We have bits in the softc that tell us
what kind of power control scheme the controller uses, rather than
relying on being able to enumerate them all.  Cardbus bridges are
numerous, but nearly all implement the i82365sl-DF scheme (well, a few
implement cirrus CL-PD67xx, but those were made by Cirrus Logic!).

Add a pointer back to the softc in each pcic_slot so we can access
these flags.

Add comments that talk about the issues here.  Also note in passing
that there are two differ Vpp schemes in use and that we may need to
adjust the code to deal with both of them.  Note why it usually works
now.

We have 5 power management modes right now: KING, AB, DF, PD and VG.
AB is for the i82365 stpes A, B and C.  DF is for step DF.  PD is the
cirrus logic extensions for 3.3V while VG is the VADEM extensions for
3.3V.  KING is for the IBM KING controller found on some old cards.
# I'm looking for one of those old cards or a laptop that has the KING
# bridge in it.

We have to still cheat and treat the AB parts like the DF parts
because pci isn't here yet.  As far as I can tell, this is harmless
for actual old parts and necessary to work with 3.3V cards in some
laptops.

This almost eliminates all tests for controller in the code.  There
are still a few unrelated to power that need taming as well.
2001-05-21 04:44:14 +00:00
Warner Losh
e67316366d Next step towards pcic_pci: the ability to allocate mapped memory in attach.
o Introduce flags word to the softc.  This will be used to control various
  aspects of the driver.  Right now there are two bits defined, PCIC_IO_MAPPED
  and PCIC_MEM_MAPPED.  One for ISA cards that are I/O mapped, the other is
  for PCI cards that are memory mapped.  Only the ISA side is implemented
  with this commit.
o Introduce a pcic_dealloc which will cleanly dealloc resources used.  Right
  now it is only supported when called from probe/attach.
o Keep track of resources allocated in the pcic_softc.
o move pcictimeout_ch to the softc so we can support multiple devices
  in polling mode.
o In ISA probe, set PCIC_IO_MAPPED.
o Introduce and compute the slot mask.  This will be used later when
  we expand the number of slots on ISA from 2 to 4.  In such a case, we
  appear to have to use polling mode otherwise we get two different cards
  trying to drive the same interrupt line.  I don't have hardware to
  test this configuration, so I'll stop here.
2001-05-21 03:22:52 +00:00