Monday, December 5, 2011

Setup PCI-Pcmcia Bridges Under Linux.

Linux Kernel

The implementation model of linux pcmcia is changing:

2.2.13+ Kernels

There is no kernel support, so the pcmcia-cs standalone package as suppported by David Hinds must be used
2.4.1+ Kernels

There is limited kernel support for pci+pcmcia, basically the "yenta_socket" module.
It appears that the functionality from David Hinds' external i82365 module has been taken (more likely it was re-implemented) and split into two parts, "i82365" for ISA bridges and "yenta_socket" for PCI bridges, but strangely enough they have not implemented the "irq_mode" option for the "yenta_socket" module, so that ISA interrupts are used instead for PCI bridges. (I just can not get my head around that one!)
If the kernel version "yenta_socket" module that you use does not route PCI interrupts to Elan's PCI adapter then it will be neccessary to continue to use the standalone package. Just "cat /proc/interrupts" and if the interrupt count for the pcmcia card that you inserted remains obstinately at zero, then the interrupt is not working and is probably not routed correctly.
i82365 module from the pcmcia-cs package with 2.4.1+ Kernels

To use the i82365 module from the pcmcia-cs package one needs to rebuild the kernel without either the "yenta-socket" module or "yenta-socket" included in the kernel. To do this, using "make menuconfig", go to the General setup page and from there go to the PCMCIA/CardBus support page and de-select the PCMCIA/CardBus support.
After recompiling and rebooting with the yenta-less kernel one needs to build the standalone pcmcia-cs package. The pcmcia-cs make program will detect the fact that it is a yenta-less kernel and will compile the external i82365 module.
i82365 module parameters with the pcmcia-cs package

For Elan's P111 card The i82365 options can be set in the pcmcia configuration files as specified below, OR can be setup via the standard module parameter setting method by adding the following line to "/etc/modules.conf"

options i82365 irq_mode=0 pci_csc=0 poll_interval=100

2.6.1+ Kernels

Apparently the standalone package will no longer be supported with respect to this 2.6.X kernel, see Notes about PCMCIA in the 2.4 kernel by David Hinds for details.
But the good news is that the kernel YENTA support now seems to route the controller's pci IRQ through to the pcmcia card correctly. Thus no patches are required to get the pseries adapter cards working with 2.6.X kernels.
2.4.25 Kernel patch for pci irq mode

Now the yenta_socket module nearly works, but fails to route the controller's pci IRQ through to the pcmcia card. Here you will find the pci-irq-mode patch for kernels 2.4.25 and 2.4.26 that will, in the case that no ISA interrupt can be found, route the interrupt via the PCI controller card. To use this patch:

cd /usr/src/linux
patch -b -z .orig -p0 < /path/to/pci-irq-mode.patch
mkdir /boot/2.4.25-pci-irq-mode

and edit the "/etc/lilo.conf" file to contain:

image = /boot/2.4.25-pci-irq-mode/vmlinuz
root=/dev/????
label = yenta-2.4.25
read-only

This patch also treats the ENE 1410 chipset identically to the TI 1410 chipset.

This patch has been tested with a P111 (ENE 1410) and pcmcia-cs-3.2.7

note: Since it is reported that this routing mucks up serial irq's you must use this patch at your own risk.

Known Problems
Shared Interrupts

Some of the pcmcia card drivers don't properly support the sharing of interrupts. One particular example is the ide driver for flash-ATA cards. The observed effect is that a single flash card works fine no matter which slot on a P423 or P222 (for example) it is inserted into. However the act of inserting a second flash/ATA card is to lock-up the LINUX kernel, at which point one of the diagnostic LEDs on the adaptor card will show that an interrupt is active.
note that more recent versions of the kernel are getting better at sharing interrupts, so this might not be a problem any longer
Texas Instruments Controllers

Adaptors featuring TI controller chips include:

P111 (single rear slot)
P222 (twin rear slot)
P423 and derivative models - front/external, twin slot.

Fron Linux's point of view only the controller chip is significant, all models using a TI chip are expected to behave in the same way.

The PCIC type is i82365 and the necessary PCIC options are:

"irq_mode=0 pci_csc=0 poll_interval=100"

and are unfortunately set in different configuration files depending on the distribution. Some of the major distributions are listed below with the configuration filenames.

The effect of these options are:

to disable ISA interrupts and to use PCI interrupts only for the pcmcia cards
to disable Card Status interrupts altogether and just poll once a second for insertions

The reason for polling the controller for Card Status Changes is that some drivers do not seem to be able to share interrupts, the example that we at Elan found was the "ide_cs" module. It is the driver used for ATA flash cards. And since doing a poll is unlikely to strain your PC, it is easier to just always do it.

Slackware 7.1+, 8.0+, 9.0+

The configuration file is:

/etc/rc.d/rc.pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=0 pci_csc=0 poll_interval=100"
Debian 2.2

The configuration file is:

/etc/pcmcia.conf OR /etc/init.d/pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=0 pci_csc=0 poll_interval=100"
SuSE 7.0

The configuration file is:

/etc/rc.config

The options are:

PCMCIA="i82365"
PCMCIA_PCIC_OPTS="irq_mode=0 pci_csc=0 poll_interval=100"
Red Hat 7.0

The configuration file is:

/etc/sysconfig/pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=0 pci_csc=0 poll_interval=100"

Cirrus Logic Controllers

Models featuring a CL controller include:

P113 and P223 (front slot models)
P114 and P224 (external models)
Various combination models, eg. the P116 which has one rear and one front slot.

From Linux's point of view, only the controller chip is significant, so all CL models would be expected to behave in the same way.

The PCIC type is i82365 and the necessary PCIC options are:

irq_mode=1 pci_csc=0 poll_interval=100"

and are unfortunately set in different configuration files depending on the distribution. Some of the major distributions are listed below with the configuration filenames.

Please note that the irq_mode parameter setting required is different to that in the Texas Instrument controller.

The effect of these options are:

to disable ISA interrupts and to use PCI interrupts only for the pcmcia cards
to disable Card Status interrupts altogether and just poll once a second for insertions

The reason for polling the controller for Card Status Changes is that some drivers do not seem to be able to share interrupts, the example that we at Elan found was the "ide_cs" module. It is the driver used for ATA flash cards. And since doing a poll is unlikely to strain your PC, it is easier to just always do it.

Slackware 7.1+, 8.0+, 9.0+

The configuration file is:

/etc/rc.d/rc.pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=1 pci_csc=0 poll_interval=100"
Debian 2.2

The configuration file is:

/etc/pcmcia.conf OR /etc/init.d/pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=1 pci_csc=0 poll_interval=100"
SuSE 7.0

The configuration file is:

/etc/rc.config

The options are:

PCMCIA="i82365"
PCMCIA_PCIC_OPTS="irq_mode=1 pci_csc=0 poll_interval=100"
Red Hat 7.0

The configuration file is:

/etc/sysconfig/pcmcia

The options are:

PCIC=i82365
PCIC_OPTS="irq_mode=1 pci_csc=0 poll_interval=100"

Modules Installed

Before a pcmcia card is inserted a module listing using "lsmod" should show
ds 6088 1
i82365 21340 1
pcmcia_core 48448 0 [ds i82365]

though the module sizes might be different in different versions
Card Manager

The daemon "cardmgr" should have been started at boot time, but check the output of "ps faxw". It is the program that checks the card status and subsequently loads and configures drivers as and when pccards are inserted or removed.
Interrupts

Check "/proc/interrupts" to ensure that your card is actually working in interrupt mode and not polling. Check that the interrupt count is incrementing:

0: 60331887 XT-PIC timer
1: 24 XT-PIC keyboard
2: 0 XT-PIC cascade
3: 95839 XT-PIC wvlan_cs
4: 113 XT-PIC serial
8: 1 XT-PIC rtc
9: 1779 XT-PIC eth0
10: 274972 XT-PIC WD8013
13: 0 XT-PIC fpu
14: 1413563 XT-PIC ide0
15: 526115 XT-PIC ide1
NMI: 0

P111 example

Various pcmcia cards have been tested running with our P111 card, and here are two example "dmesg" listings to show what you should see if all is working
Kernel - 1

[snip]
Linux PCMCIA Card Services 3.1.19
kernel build: 2.2.16 #10 Fri Jul 21 14:27:25 BST 2000
options: [pci] [cardbus] [pnp]
PnP: PNP BIOS installation structure at 0xc00fc4c0
PnP: PNP BIOS version 1.0, entry at f0000:c4e8, dseg at f0000
Intel PCIC probe:
TI 1211 rev 00 PCI-to-CardBus at slot 00:11, mem 0x68000000
host opts [0]: [pci only] [pci irq 3] [lat 32/176] [bus 32/34]
PCI card interrupts, PCI status changes
[snip]
Kernel - 2

[snip]
Linux PCMCIA Card Services 3.1.19
kernel build: 2.2.13 #24 Fri Jul 21 15:37:31 BST 2000
options: [pci] [cardbus] [pnp]
PCI routing table version 1.0 at 0xfdbd0
PnP: PNP BIOS installation structure at 0xc00fbd80
PnP: PNP BIOS version 1.0, entry at f0000:bda8, dseg at f0000
Intel PCIC probe:
TI 1410 rev 01 PCI-to-CardBus at slot 00:0c, mem 0xe9001000
host opts [0]: [pci only] [pci irq 5] [lat 64/176] [bus 236/0]
PCI card interrupts, PCI status changes
[snip]
P222 example

A 32bit single function Ethernet Cardbus-card and a 6bit dual function Ethernet and modem card have been tested simultaneously in this adaptor.
Here are some diagnostics:
PCI Bus

First verify that the P222 is visible to the kernel via the PCI bus.

The output of the linux command "lspci" should look something like:

00:00.0 Host bridge: VIA Technologies, Inc. VT82C691 [Apollo PRO] (rev 44)
00:01.0 PCI bridge: VIA Technologies, Inc. VT82C598 [Apollo MVP3 AGP]
00:07.0 ISA bridge: VIA Technologies, Inc. VT82C596 ISA [Apollo PRO] (rev 23)
00:07.1 IDE interface: VIA Technologies, Inc. VT82C586 IDE [Apollo] (rev 10)
00:07.3 Host bridge: VIA Technologies, Inc.: Unknown device 3050 (rev 30)
00:09.0 Ethernet controller: Lite-On Communications Inc LNE100TX (rev 20)
00:0a.0 Ethernet controller: Lite-On Communications Inc LNE100TX (rev 20)
00:0c.0 CardBus bridge: Texas Instruments PCI1420
00:0c.1 CardBus bridge: Texas Instruments PCI1420
01:00.0 VGA compatible controller: ATI Technologies Inc 3D Rage LT Pro AGP-133 (rev dc)

The important bit being two entries for "CardBus bridge", because it's got two slots
Kernel - example

Check that Card Services are operating by viewing the output of the "dmesg" linux command:

Linux version 2.2.16 (root@olech) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)) #5 Mon Sep 25 10:13:10 /etc/localtime 2000
Detected 601367 kHz processor.
Console: colour VGA+ 132x44
Calibrating delay loop... 1199.31 BogoMIPS
[snip]
Linux PCMCIA Card Services 3.1.20
kernel build: 2.2.16 #5 Mon Sep 25 10:13:10 /etc/localtime 2000
options: [pci] [cardbus]
PCI routing table version 1.0 at 0xfdbd0
00:0c.0 -> irq 5
00:0c.1 -> irq 5
Intel PCIC probe:
TI 1420 rev 00 PCI-to-CardBus at slot 00:0c, mem 0xea002000
host opts [0]: [pci only] [pci irq 5] [lat 64/176] [bus 224/0]
host opts [1]: [pci only] [pci irq 5] [lat 64/176] [bus 228/0]
PCI card interrupts, polling interval = 1000 ms
cs: cb_alloc(bus 224): vendor 0x1011, device 0x0019
cs: IO port probe 0x0100-0x02ff: clean.
cs: IO port probe 0x0330-0x04ff: excluding 0x4d0-0x4d7
cs: IO port probe 0x0800-0x08ff: clean.
cs: IO port probe 0x0a00-0x0aff: clean.
cs: IO port probe 0x0c00-0x0cff: excluding 0xcf8-0xcff
cs: cb_config(bus 224)
fn 0 bar 1: io 0x200-0x27f
fn 0 bar 2: mem 0x600c0000-0x600c03ff
fn 0 rom: mem 0x60080000-0x600bffff
irq 5
cs: cb_enable(bus 224)
bridge io map 0 (flags 0x21): 0x200-0x27f
bridge mem map 0 (flags 0x1): 0x60080000-0x600c0fff
tulip_attach(device e0:00.0)
tulip.c:v0.91g-ppc 7/16/99 becker@cesdis.gsfc.nasa.gov (modified by danilo@cs.uni-magdeburg.de for XIRCOM CBE, fixed by Doug Ledford)
eth3: Digital DS21143 Tulip rev 65 at 0x200, 00:E0:98:76:1F:5F, IRQ 5.
eth3: EEPROM default media type Autosense.
eth3: Index #0 - Media MII (#11) described by a 21142 MII PHY (3) block.
eth3: MII transceiver #0 config 3000 status 7809 advertising 01e1.
cs: memory probe 0xa0000000-0xa0ffffff: clean.
3c574_cs.c v1.08 9/24/98 Donald Becker/David Hinds, becker@cesdis.gsfc.nasa.gov.
eth4: 3Com 3c574 at io 0x340, irq 5, hw_addr 00:00:86:34:B1:BF.
ASIC rev 10, 64K FIFO split 1:1 Rx:Tx, autoselect MII interface.
tty00 at 0x03f8 (irq = 5) is a 16550A
[snip]

The pcmcia cards here are 32bit single function Ethernet(eth3) Cardbus-card and a 6bit dual function Ethernet(eth4) and modem (tty00) card. The drivers managed to share successfully and the modem and 32but ethernet card were working at the same time.
P116 example

A 32bit single function Ethernet Cardbus-card and a 6bit dual function Ethernet and modem card have been tested simultaneously in this adaptor.
Here are some diagnostics:
Kernel - example

Check that Card Services are operating by viewing the output of the "dmesg" linux command:

[snip]
Starting PCMCIA services: modulesLinux PCMCIA Card Services 3.1.20
kernel build: 2.2.16 #5 Mon Sep 25 10:13:10 /etc/localtime 2000
options: [pci] [cardbus]
PCI routing table version 1.0 at 0xfdbd0
Intel PCIC probe:
Cirrus PD6729 rev 00 PCI-to-PCMCIA at slot 00:0b, port 0xe000
host opts [0]: [pci only] [pci irq 5] [1/5/0] [1/20/0]
host opts [1]: [pci only] [pci irq 5] [1/5/0] [1/20/0]
PCI card interrupts, polling interval = 1000 ms
cardmgr.
cardmgr[57]: starting, version is 3.1.20
[snip]
cardmgr[57]: watching 2 sockets
cs: IO port probe 0x0100-0x02ff: clean.
cs: IO port probe 0x0330-0x04ff: excluding 0x4d0-0x4d7
cs: IO port probe 0x0800-0x08ff: clean.
cs: IO port probe 0x0a00-0x0aff: clean.
cs: IO port probe 0x0c00-0x0cff: excluding 0xcf8-0xcff
[snip]
Diagnostics

The most useful diagnostic tools are:

dmesg
lsmod
lspci

Problems

Typically most problems come from not getting the configuration parameters right
Examples of Incorrect Configuration

Here the P111 has been configured for ISA interrupts, and the card might appear to work if the pcmcia driver has a fall back option of using polling. But by repeatedly looking at /proc/interrupts it will be seen that the interrupt count is not incrementing. The "dmesg" output will show that pci interrupts are not configured:

[snip]
Linux PCMCIA Card Services 3.0.14
kernel build: 2.2.13 #3 Thu Jun 15 11:10:29 BST 2000
options: [pci] [cardbus]
Intel PCIC probe:
Unknown [0x104c 0xac1e] PCI-to-CardBus at bus 0 slot 17, mem 0x68000000, 1 socket
host opts [0]: [no pci irq] [lat 32/176] [bus 32/34]
ISA irqs (default) = 3,4,5,7,11,12 polling interval = 1000 ms
[snip]
A customer example

One of our customers managed to get a P011 adapter card working with a 2.1.18 kernel and pcmcia 3.1.22. He reports that PCIC_OPTS="irq_mode=0" alone did not work, giving:

[snip]
Intel PCIC probe:
TI 1211 rev 00 PCI-to-CardBus at slot 00:11, mem 0x68000000
host opts [0]: [pci only] [pci irq 3] [lat 32/176] [bus 32/34]
*NO* card interrupts, polling interval = 1000ms
[snip]

However using pcmcia-cs-3.1.22/debug-tools/dump_pirq to identify the correct IRQ number (11 in his case), he found that PCIC_OPTS="irq_mode=0 pci_irq_list=11,11" worked!
I have not verified that, but maybe it's something to try when all else fails!

No comments:

Post a Comment