Commit Graph

146 Commits

Author SHA1 Message Date
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
Warner Losh
69ffb52731 Two comments and one bug fix:
o Add defines for the VS[12]# bits in register 0x16.
o Add comment about what we're doing reading register 0x16 (PCIC_CDGC)
  in the DF case.
o Check bit VS1# rather than a random bit I was checking due to a bogus
  transcrition on my part from nakagawa-san's article.
o Add note about IBM KING and 3.3V operation from information larned from
  wildboard.
2001-05-21 00:55:44 +00:00
Warner Losh
aa3a855755 Add back the plain i82365 to the list of bridges that do special
things to get 3.3V.  It appears that some cardbus chipsets have id
registers that say they are C step parts, but they really support the
DF step 3.3V functionality.

# Need to verify that IBM KING is handled properly since the MISC1
# register is really a cirrus logic only register.
2001-05-19 06:36:09 +00:00
Warner Losh
0eee936491 Initialize cinfo structure at compile time rather than run time since
they are now constant.
2001-05-19 06:17:37 +00:00
Warner Losh
11695ef016 Now that we've moved the mecia support out of pcic.c to its own
driver, we no longer need to go through the cinfo.XXXX indirections.
restore the direct calls that were replaced earlier.
2001-05-19 05:50:42 +00:00
Warner Losh
bc0f2245d1 Move ISA specific code into pcic_isa. This is the probe routine, the
get/setb1 routines.  Also expose clrb and setb as pcic_{clrb,setb} so
we can use it from the probe.  pcic_probe is no longer needed.
2001-05-19 05:21:23 +00:00
Warner Losh
08db6b5c8e It turns out that Intel's i82365sl-DF step has the same ID as the VLSI
82C146.  The Intel i82365SL-DF supports 3.3V cards.  The Step A/B/C
parts do not appear to support this.  This is hard to know for sure
since it was deduced from "compatible" parts' data sheets and the
article mentioned below.

Rework the VLSI detection to be a little nicer and not depend on
scanning cards twice.  This would allow bad VLSI cards to coexist with
a good intel card, for example.  We now detect i82365SL-DF cards where
before we'd detect a VLSI.  For the most part, this is good, but we
run a small chance of detecting a single slot 82C146 as a i82365SL-DF.
Since I can't find a datasheet for the 82c146, I don't know if this is
a problem or not.

This work is based on an excellent article, in Japanese, by NAKAGAWA,
Yoshihisa-san that appeared in FreeBSD Press Number 4.  He provided a
patch against PAO3 in his article.  Since the pcic.c code has changed
some since then, I've gone ahead and cleaned up his patch somewhat and
changed how the code detects the buggy '146 cards.

I also removed the comment asking if there were other cards that
matched the 82C146 since we found one and additional information isn't
necessary.
2001-05-19 04:53:20 +00:00
Warner Losh
5a695e4878 Separate out isa attachment to its own file. The pci attachment will
soon attach directly to pcic rather than the kludge pci-pcic device we
have now.

In some ways, this is similar to the work PAO3 did to try to support
cardbus bridges.  In some ways different.  This and future commits
will be taking from the spirit of many of those changes.  pcicvar.h is
completely different from the pcicvar.h that appeared in PAO3, but
similar in concept.
2001-05-16 07:32:04 +00:00
Warner Losh
fae3b4e989 The mecia support has moved to the mecia driver, so remove the copy of
it here.
2001-05-15 23:50:58 +00:00
Warner Losh
ca4d6d4f8c {G,S}ET_UNIT are now unused, gc them 2001-05-15 03:32:45 +00:00
Warner Losh
f81f90ff95 It turns out that pcic_slot::slotnum was really unused, so don't set
it.
2001-05-14 23:14:23 +00:00
Warner Losh
12d6689ccd Remove static array of slots. We now have state information for each
slot in a softc for each unit that we probe.  Also remove validunits
static, since it is no longer necessary.
2001-05-14 23:08:58 +00:00
Warner Losh
07e0ca29b5 Fix the so called "static bug" in polling mode. Some desktop cards
have bad grounding characteristics which allow small static discharges
(or sunspots, we're not 100% sure which) to reach the bridge chip.
This causes the bridge chip to wedge/reset itself.  There's no known
cure short of rebooting.

The bug manifests itself by the STAT_CHG return 0xff when read.  This
is impossible because the upper bits are reserved (and therefore
zero).  In addition, some of the lower bits are one only for memory
cards, which OLDCARD doesn't support, so if they are set, something
seriously foobar'd is going on.

So far we've seen this in exactly one brand of pcmcia <-> isa bridge
which plug and play identifies only as "VIA PCMCIA CARD".  This card
just has buffers on the isa card and the actual bridge chip on the
remote slot, which is connected by long ribbon cables.  We think this
long cable run, coupled with the lack of coupling capacitors is a
major reason why it is so static sensitive while its bretheren aren't.

Work Supported by: Timing Solutions, Inc.

MFC After: 3 days
2001-05-14 21:08:20 +00:00
Warner Losh
3ad72a92eb When activating or deactivating a resource, only attempt to deal with
the resource activation if we're dealing with our grandchild.
Otherwise, we run into two problems.  One, if the pccard layer wanted
to allocate and activate something, we'd wind up trying to do the
wrong thing twice: the ivars are wrong and we don't want the bridge to
map the resource to the slot.  If we're more than a grandchild, then
who knows what kind of ivar is present.  In either of these cases, we
just pass it up the food chain.
2001-05-14 04:53:02 +00:00
Warner Losh
180c9afb62 Return errors for unsupported operations on pcic_get_res_flags rather
than 0.
2001-05-13 04:44:45 +00:00
Warner Losh
87c53da12e Change #ifdef PC98 to #ifdef MECIA_SUPPORT and define MECIA_SUPPORT
when PC98 is defined.  This is in perparation for a mecia driver
separate from pcic, assuming that all goes well with that effort.
MECIA_SUPPORT won't be removed until after that support is working.
2001-05-13 04:16:09 +00:00
Warner Losh
804e80065b o Get rid of static array of slots in pccard layer. Move this to the
softc.
o Store pointers to softc in dev_t in si_drv1.
o Change 'kludge version' to 'classic version' since things are getting less
  kludgy.
o Minor code shuffling so that we probe and attach the pccard slots.
o Minor style(9) changes.
2001-05-13 01:44:27 +00:00
Duncan Barclay
7b8ec2c952 Use enumeration values for CARD_SET_RES_FLAGS.
Remove panic on out of range io window and return ENXIO. Add a similar
check for memory windows.

Approved by:	imp
2001-05-08 23:59:13 +00:00
Warner Losh
bc5797c7de Set the slot pointer in the pc98 case. Correct the name of the bridge
chip to the one that the Japanese use.  Now we get insert/remove
events on my PC-9821Ne.  More work in bus space is needed to make
drivers work.

MFC after: 3 days
2001-05-07 22:28:05 +00:00
Warner Losh
a66173abd2 Disable the card after sending the removed event up to the pccard
layer.  This fixes an ordering problem that would cause the ISR for
the device to run with now power applied to the device.  Most cards
failed to deal with this gracefully, and thus would hang on card
eject.

The power down event, for those keeping score, is what causes the
interrupt for the card.

Many folks in the Japanese nomads list have reported this, so I'll be
MFCing quickly for their benefit.

Submitted by: Masayuki FUKUI
MFC after: 2 days
2001-05-07 16:50:34 +00:00
Warner Losh
04a3a05381 Set the device name for NEC PC98 PCMCIA Controller on boot.
# We really need to allocate i/o ports for it, but I need to learn
# the pc98 bus space better before attempting that.
2001-04-21 07:08:03 +00:00
Warner Losh
3fb5ffd286 Indirect off cinfo rather than calling pcic_ functions directly. This
means that the pcic98 functionality might now work (I've tested it on
my pcic machine, but not the pcic98).  Since these functions are
rarely called, it is unlikely that this will have a measurable impact
on performance.
2001-04-19 05:45:51 +00:00
Warner Losh
7402675de4 First cut at bringing NEC PC98 original pccard bridge code back into
FreeBSD.  This code doesn't work just yet, but does compile.  We need
to start indirecting via the cinfo pointers, rather than directly
calling pcic_*.  There may be other issues as well, but you gotta
start somewhere.

Obtained from: PAO3
2001-04-19 00:04:08 +00:00
Warner Losh
e5eac10b13 Add #define for IBM3765.
Fix SWAMPBOX.  It had actiontec's ID.
Reorder pnpids so they are in alphabetical order.
2001-04-11 20:18:29 +00:00
Warner Losh
cc2310a949 Axe a few __P() while I'm in the neighborhood. 2001-03-22 05:49:18 +00:00
Warner Losh
36260de0cf Lots of minor cleanup, plus a couple of interesting things.
o Attempt to disable the slot when we detect that there are problems with
  it in our ISR.  This should make polling mode work better for more cards,
  but more work may be needed.  This "disabling" sets the card interrupt
  register to 0.  This worked for me for lots of tests in polling mode.
o Now that I've found datasheets, fix a boatload of magic numbers in the
  source to make it easier to understand.
o Use a table of names rather than a big case statement.
o Cull a few of the "unused" controller types that we map to other times
  that were a vestiage of PAO code that we never merged in the same way.
o Enforce legal IRQs.  You are no longer allowed to try to use IRQs that
  will fail on all known ISA/PCI <-> PCMCIA bridges.  The bridges do not
  have pins for these illegal interrupts, and all of them are listed as
  reserved and/or illegeal in the datasheets depending on which one you
  look at.
o Add comments about how IBM-AT based computers and NEC PC-98 based computers
  map these interrupts and which ones are valid.
o Always clear the bit that steers the management interrupt either to the
  value listed in the PCIC_STAT_INT register.  I've seen this bit get set
  on suspend/resume and after windows boot, and it does't hurt to clear it.
  NOTE: this might mean we can share this interrupt in the future.
2001-03-19 07:10:38 +00:00
Duncan Barclay
25522b4ef4 Fix a minor bug that prevents NEWBUS users from setting more than
one memory map. The memory window for the PCIC is identifed by the resource id
for NEWSBUS drivers. pccardd always uses window 0 and rid 0 when setting maps
up. This fix does not affect pccardd's handling of common memory for ed cards.

Reviewed by:	imp
2001-01-09 23:39:32 +00:00
Garrett Wollman
0a2c3d48c6 select() DKI is now in <sys/selinfo.h>. 2001-01-09 04:33:49 +00:00
Warner Losh
486d464d74 o Now that I've had time to test the new interface, reintegrate it back in.
o Fix OLDCARD to use the new interface.
o Rename the offsetp argument to deltap to more closely reflect what it
  is returning (it returns the delta from the requested value to the actual
  value).
o Remove duplicate $FreeBSD$ in pccbb.c
o Allow deltap to be NULL.
o Convert new isa pcic driver and add XXX comments that this function isn't
  actually implemented there (which means that NEWCARD pccard stuff won't
  work there until it is).
o Revert attempts to make old inferface work in NEWCARD.

Subitted by: peter (Parts of the new version code)
2001-01-07 16:31:09 +00:00
MIHIRA Sanpei Yoshiro
23f344f985 add PNPID for PnP PCMCIA, SCM SwapBox Classic X2P.
PR:		kern/23344 (Kaho Toshikazu <kaho@elam.kais.kyoto-u.ac.jp>)
2000-12-11 15:02:50 +00:00
Poul-Henning Kamp
db7e3af111 Remove unneeded #include <machine/clock.h> 2000-10-15 14:19:01 +00:00