| 1 | <html> |
|---|
| 2 | <body> |
|---|
| 3 | |
|---|
| 4 | <h2>Using a PCI Multi I/O Controller for extending the PC I/O ports</h2> |
|---|
| 5 | |
|---|
| 6 | <p>Today's personal computers feature dozens of I/O ports, like USB, |
|---|
| 7 | RS232, PS/2, Gameport, Parallel Port, SATA, etc. Only a few are interesting |
|---|
| 8 | for connecting own devices, in particular</p> |
|---|
| 9 | |
|---|
| 10 | <ul> |
|---|
| 11 | <li>USB, with the advantage of being future-proof, but |
|---|
| 12 | very complex from the programmer's view</li> |
|---|
| 13 | <li>RS232, with the advantage of having a simple structure |
|---|
| 14 | and being very old, but still widely-used as an industry |
|---|
| 15 | standard</li> |
|---|
| 16 | <li>Parallel Port (IEEE 1284), being the only parallel interface |
|---|
| 17 | but almost died off.</li> |
|---|
| 18 | </ul> |
|---|
| 19 | |
|---|
| 20 | <p>In this article, I'll talk about the parallel port. It features 3 octett registers |
|---|
| 21 | with</p> |
|---|
| 22 | <ul> |
|---|
| 23 | <li>one bidirectional (tristate) data register</li> |
|---|
| 24 | <li>one status register (4 input bits, one bit capable of interrupt)</li> |
|---|
| 25 | <li>one control register (4 output bits)</li> |
|---|
| 26 | </ul> |
|---|
| 27 | <p>So you can use 12 input, 4 output bits or 12 output, 4 input bits, respectively. |
|---|
| 28 | If you need more I/O pins, you are lost on ordinary PC platforms.</p> |
|---|
| 29 | |
|---|
| 30 | <h3>Extending with an PCI Parallel Port controller card</h3> |
|---|
| 31 | <p>There are multiple vendors that sell those PCI Parallel Port controller cards with |
|---|
| 32 | one or more parallel ports. I've buyed one of them and built it straight into my |
|---|
| 33 | linux box:</p> |
|---|
| 34 | |
|---|
| 35 | <pre> |
|---|
| 36 | # lspci |
|---|
| 37 | 00:0c.0 Communication controller: NetMos Technology PCI 9815 Multi-I/O Controller (rev 01) |
|---|
| 38 | Subsystem: LSI Logic / Symbios Logic Device 0020 |
|---|
| 39 | Flags: medium devsel, IRQ 11 |
|---|
| 40 | I/O ports at 1010 [size=8] |
|---|
| 41 | I/O ports at 1018 [size=8] |
|---|
| 42 | I/O ports at 1020 [size=8] |
|---|
| 43 | I/O ports at 9000 [size=8] |
|---|
| 44 | I/O ports at 1028 [size=8] |
|---|
| 45 | I/O ports at 1000 [size=16] |
|---|
| 46 | Kernel driver in use: parport_pc |
|---|
| 47 | Kernel modules: parport_pc |
|---|
| 48 | </pre> |
|---|
| 49 | |
|---|
| 50 | <p>Like you see, it offers various I/O ports. After all, there are now two more |
|---|
| 51 | parallel ports available:</p> |
|---|
| 52 | |
|---|
| 53 | <pre> |
|---|
| 54 | # ls -l /dev/parport* |
|---|
| 55 | crw-rw---- 1 root lp 99, 0 2009-09-24 17:28 /dev/parport0 |
|---|
| 56 | crw-rw---- 1 root lp 99, 1 2009-09-24 17:28 /dev/parport1 |
|---|
| 57 | crw-rw---- 1 root lp 99, 2 2009-09-24 17:28 /dev/parport2 |
|---|
| 58 | </pre> |
|---|
| 59 | |
|---|
| 60 | <p>If you take a short look at dmesg (excerpt), you'll notice the capabilities |
|---|
| 61 | of those ports</p> |
|---|
| 62 | |
|---|
| 63 | <pre> |
|---|
| 64 | # dmesg |
|---|
| 65 | [ 15.697123] parport_pc 00:09: reported by Plug and Play ACPI |
|---|
| 66 | [ 15.697352] parport0: PC-style at 0x378 (0x778), irq 7, dma 3 [PCSPP,TRISTATE,COMPAT,EPP,ECP,DMA] |
|---|
| 67 | [ 15.726365] ACPI: I/O resource piix4_smbus [0xe800-0xe807] conflicts with ACPI region SM00 [0xe800-0xe806] |
|---|
| 68 | [ 15.726483] ACPI: Device needs an ACPI driver |
|---|
| 69 | [ 15.726570] piix4_smbus 0000:00:04.3: SMBus Host Controller at 0xe800, revision 0 |
|---|
| 70 | [ 15.802653] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 11 |
|---|
| 71 | [ 15.802749] PCI: setting IRQ 11 as level-triggered |
|---|
| 72 | [ 15.802767] parport_pc 0000:00:0c.0: PCI INT A -> Link[LNKA] -> GSI 11 (level, low) -> IRQ 11 |
|---|
| 73 | [ 15.802868] PCI parallel port detected: 9710:9815, I/O at 0x1010(0x1018) |
|---|
| 74 | [ 15.802916] parport1: PC-style at 0x1010 (0x1018) [PCSPP,TRISTATE] |
|---|
| 75 | [ 15.915438] input: PC Speaker as /devices/platform/pcspkr/input/input4 |
|---|
| 76 | [ 15.942662] PCI parallel port detected: 9710:9815, I/O at 0x1020(0x9000) |
|---|
| 77 | [ 15.942723] parport2: PC-style at 0x1020 (0x9000) [PCSPP,TRISTATE] |
|---|
| 78 | </pre> |
|---|
| 79 | |
|---|
| 80 | <p>The Parallel port driven by the Super I/O port on the mainboard features things |
|---|
| 81 | like <i>COMPAT, EPP, ECP, DMA</i> modes, while the extended ports only give you the |
|---|
| 82 | basics like <i>PCSPP, TRISTATE</i>. However, this is enough for ordinary programming |
|---|
| 83 | (directly accessing the registers without any accleration protocols): All the programs |
|---|
| 84 | in this project are running on these ports. Since you can use them all together at the |
|---|
| 85 | same time, you get in total:</p> |
|---|
| 86 | |
|---|
| 87 | <ul> |
|---|
| 88 | <li>3 bidirectional registers = <b>24 I/O</b>, individually tunable tristate or not</li> |
|---|
| 89 | <li>3 status registers, having totally <b>12 input</b> bits, thereof <b>3 interrupt</b> bits</li> |
|---|
| 90 | <li>3 control registers, having totally <b>12 output</b> bits</li> |
|---|
| 91 | </ul> |
|---|
| 92 | |
|---|
| 93 | <p>Summing up, we can get at maximum <b>32 in/out</b> and <b>12 out/in</b>, respectively. |
|---|
| 94 | Combining with Linux kernel space programming, that's a powerful setup for only some euros (and |
|---|
| 95 | you can even buy another PCI controller card to get even more registers) - compared to these |
|---|
| 96 | very expensive measurement system controllers (above 500 Euros...).</p> |
|---|