Import 2.1.99pre2
[davej-history.git] / Documentation / mca.txt
blob23df12b57d653ceb1b5eb708e449ae372c0390f4
1 i386 Micro Channel Architecture Support
2 =======================================
4 MCA support is enabled using the CONFIG_MCA define.  A machine with a MCA
5 bus will have the kernel variable MCA_bus set, assuming the BIOS feature
6 bits are set properly (see arch/i386/boot/setup.S for information on
7 how this detection is done).
9 Adapter Detection
10 =================
12 The ideal MCA adapter detection is done through the use of the
13 Programmable Option Select registers.  Generic functions for doing
14 this have been added in include/linux/mca.h and arch/i386/kernel/mca.c.
15 Everything needed to detect adapters and read (and write) configuration
16 information is there.  A number of MCA-specific drivers already use
17 this.  The typical probe code looks like the following:
19         #include <linux/mca.h>
21         unsigned char pos2, pos3, pos4, pos5;
22         struct device* dev;
23         int slot;
25         if( MCA_bus ) {
26                 slot = mca_find_adapter( ADAPTER_ID, 0 );
27                 if( slot == MCA_NOTFOUND ) {
28                         return ENODEV;
29                 }
30                 /* optional - see below */
31                 mca_set_adapter_name( slot, "adapter name & description" );
32                 mca_set_adapter_procfn( slot, dev_getinfo, dev );
34                 /* read the POS registers.  Most devices only need
35                 2 and 3 */
36                 pos2 = mca_read_stored_pos( slot, 2 );
37                 pos3 = mca_read_stored_pos( slot, 3 );
38                 pos4 = mca_read_stored_pos( slot, 4 );
39                 pos5 = mca_read_stored_pos( slot, 5 );
40         } else {
41                 return ENODEV;
42         }
44         /* extract configuration from pos[2345] and set everything up */
46 Loadable modules should modify this to test that the specified IRQ and
47 IO ports (plus whatever other stuff) match.  See 3c523.c for example
48 code.
50 Keep in mind that devices should never directly access the POS registers
51 (via inb(), outb(), etc).  While it's generally safe, there is a small
52 potential for blowing up hardware when it's done at the wrong time.
53 Furthermore, accessing a POS register disables a device temporarily.
54 This is usually okay during startup, but do _you_ want to rely on it?
55 During initial configuration, mca_init() reads all the POS registers
56 into memory.  mca_read_stored_pos() accesses that data.  mca_read_pos()
57 and mca_write_pos() are also available for (safer) direct POS access,
58 but their use is _highly_ discouraged.  mca_write_pos() is particularly
59 dangerous, as it is possible for adapters to be put in inconsistent
60 states (e.g. sharing IO address, etc) and may result in crashes, toasted
61 hardware, and operator injury.
63 User level drivers (such as the AGX X server) can use /proc/mca to find
64 adapters (see below).
66 Some MCA adapters can also be detected via the usual ISA-style device
67 probing (many SCSI adapters, for example).  This sort of thing is highly
68 discouraged.  Perfectly good information is available telling you what's
69 there, so there's no excuse for messing with random IO ports.  However,
70 we MCA people still appreciate any ISA-style driver that will work with
71 our hardware.  You take what you can get...
73 Level-Triggered Interrupts
74 ==========================
76 Because MCA uses level-triggered interrupts, a few problems arise with
77 what might best be described as the ISA mindset and its effects on
78 drivers.  These sorts of problems are expected to become less common as
79 more people use shared IRQs on PCI machines.
81 In general, an interrupt must be acknowledged not only at the ICU (which
82 is done automagically by the kernel), but at the device level.  In
83 particular, IRQ 0 must be reset after a timer interrupt (now done in
84 arch/i386/kernel/time.c) or the first timer interrupt hangs the system.
85 There were also problems with the 1.3.x floppy drivers, but that seems
86 to have been fixed.
88 IRQs are also shareable, and most MCA-specific devices should be coded
89 with shared IRQs in mind.
91 /proc/mca
92 =========
94 I did a major rewrite of /proc/mca.  It is now a directory containing
95 various files for adapters and other stuff.
97         /proc/mca/pos           Straight listing of POS registers
98         /proc/mca/slot[1-8]     Information on adapter in specific slot
99         /proc/mca/video         Same for integrated video
100         /proc/mca/scsi          Same for integrated SCSI
101         /proc/mca/machine       Machine information
103 Device drivers can easily add their own information function for
104 specific slots (including integrated ones) via the
105 mca_set_adapter_procfn() call.  Drivers that support this are ESDI, IBM
106 SCSI, and 3c523.  If a device is also a module, make sure that the proc
107 function is removed in the module cleanup.  This will require storing
108 the slot information in a private structure somewhere.  See the 3c523
109 driver for details.
111 Your typical proc function will look something like this:
113         static int
114         dev_getinfo( char* buf, int slot, void* d ) {
115                 struct device* dev = (struct device*) d;
116                 int len = 0;
118                 len += sprintf( buf+len, "Device: %s\n", dev->name );
119                 len += sprintf( buf+len, "IRQ: %d\n", dev->irq );
120                 len += sprintf( buf+len, "IO Port: %#lx-%#lx\n", ... );
121                 ...
123                 return len;
124         }
126 Some of the standard MCA information will already be printed, so don't
127 bother repeating it.  Don't try putting in more than 3K of information.
129 Enable this function with:
130         mca_set_adapter_procfn( slot, dev_getinfo, dev );
132 Disable it with:
133         mca_set_adapter_procfn( slot, NULL, NULL );
135 It is also recommended, even if you don't write a proc function, to
136 set the name of the adapter (e.g. "PS/2 ESDI Controller") via
137 mca_set_adapter_name( int slot, char* name ).  Up to 30 characters are
138 used.
140 MCA Device Drivers
141 ==================
143 Currently, there are a number of MCA-specific device drivers.
145 1) PS/2 ESDI
146         drivers/block/ps2esdi.c
147         include/linux/ps2esdi.h
148    Uses major number 36, and should use /dev files /dev/eda, /dev/edb.
149    Supports two drives, but only one controller.  Usually requires the
150    command-line args ed=cyl,head,sec
152 2) PS/2 SCSI
153         drivers/scsi/ibmmca.c
154         drivers/scsi/ibmmca.h
155    The driver for the IBM SCSI subsystem.  Includes both integrated
156    controllers and adapter cards.  May require command-line arg
157    ibmmcascsi=pun to force detection of an adapter.
159 3) 3c523
160         drivers/net/3c523.c
161         drivers/net/3c523.h
162    3Com 3c523 Etherlink/MC ethernet driver.
164 4) SMC Ultra/MCA
165         drivers/net/smc-mca.c
166         drivers/net/smc-mca.h
167         Elite/A (8013EP/A) and Elite10T/A (8013WP/A) ethernet driver
169 As well, drivers/char/psaux.c was modified to support IRQ sharing (it's
170 #ifdef CONFIG_MCA'ed, for your convenience, although PCI users might be
171 able to use it...)
173 The serial drivers were modified to support the extended IO port range
174 of the typical MCA system (also #ifdef CONFIG_MCA).
176 The following devices work with existing drivers:
177 1) Token-ring
178 2) Future Domain SCSI (MCS-600, MCS-700, not MCS-350)
179 3) Adaptec 1640 SCSI (aha1542 driver)
180 4) Buslogic SCSI (various)
182 Bugs & Other Weirdness
183 ======================
185 NMIs tend to occur with MCA machines because of various hardware
186 weirdness, bus timeouts, and many other non-critical things.  Those of
187 you who have NMI problems should probably set the CONFIG_IGNORE_NMI flag
188 somewhere.  NMIs seem to be particularly common on the model 70.
190 Various Pentium machines have serious problems with the FPU test in
191 bugs.h.  You may need to comment out the FPU test before you can even
192 boot.  This occurs, as far as we know, on the Pentium-equipped 85s, 95s,
193 and some servers.  The PCI/MCA PC 750s are fine as far as I can tell.
195 The model 80 has a raft of problems that are just too weird and unique
196 to get into here.  Some people have no trouble while others have nothing
197 but problems.  I'd suspect the problems are related to the age of the
198 average 80 and accompanying hardware deterioration.
200 Credits
201 =======
202 A whole pile of people have contributed to the MCA code.  I'd include
203 their names here, but I don't have a list handy.  Check the MCA Linux
204 home page (URL below) for an out-of-date list.
206 =====================================================================
207 http://glycerine.cetmm.uni.edu/mca
209 Chris Beauregard
210 chrisb@truespectra.com