31.2. PCMCIA in Detail

The following sections outlines what happens in your Linux system when a PCMCIA device is plugged into your machine. Components interact with each other and many requirements need to be met to support a PCMCIA device.

The following is a very rough outline of the PCMCIA initialization process in Linux:

  1. The PCMCIA bridge (or socket) must be set up properly as described in Section 31.2.1, “Bridge Initialization”. Prerequisites are:

    • an appropriate driver for the bridge

    • additional I/O and memory ranges for PC cards

  2. After the bridge is properly set up, the bridge driver detects the presence of a card and triggers its initialization as described in Section 31.2.2, “Card Initialization”:

    1. Determine the card type.

    2. Supply the proper voltage.

    3. Assign I/O and memory ranges and IRQ lines to the card.

    4. Trigger the card or device initialization by binding the appropriate card driver.

    5. For some cards, the Card Information Structure (CIS) needs to be uploaded.

  3. Finally, the interface itself is set up and ready for use. See Section 31.2.3, “Interface Setup” for details on this.

31.2.1. Bridge Initialization

Most PCMCIA bridges are PCI devices and are treated as such. The bridge initialization process can be summarized as follows:

  1. Hotplug creates a PCI event.

  2. udev calls /sbin/hwup to load the driver. /sbin/hwup checks /etc/sysconfig/hardware for an existing device configuration. If an appropriate configuration is found, that configuration is used. Otherwise /sbin/hwup calls modprobe with the modalias string provided by the kernel to load the driver module.

  3. New hotplug events are sent (one per PCMCIA socket).

  4. The following steps are omitted if only CardBus cards are used:

    1. The pcmcia_socket events trigger udev to call /sbin/hwup and load the pcmcia kernel module.

    2. All I/O and memory ranges specified in /etc/pcmcia/config.opts are added to the socket.

    3. The card services in the kernel check these ranges. If the memory ranges in /etc/pcmcia/config.opts are wrong, this step may crash your machine. See Section 31.3.1, “Machine Crashes on PCMCIA” for information about how to debug and fix this issue.

After these steps have been successfully completed, the bridge is fully initialized. After this, the card itself is initialized as described in the following section.

31.2.2. Card Initialization

The events caused by plugging in a PCMCIA card can be summarized as follows:

  1. A hotplug event occurs. For PC cards, this is a pcmcia event. For CardBus cards, this is a pci event.

  2. For any events, udev calls /sbin/hwup to load a driver module. The module name is either specified in a hwcfg* file under /etc/sysconfig/hardware or via modprobe modalias.

  3. If needed, device initialization triggers a firmware hotplug event. This searches for firmware and loads it.

  4. The device driver registers the interfaces.

After these steps have been completed, the system proceeds with interface setup as described in the next section.

If your card is a PC card, you might need some of the following parameters in /etc/sysconfig/pcmcia to get it fully supported and working flawlessly:

PCMCIA_LOAD_CIS

A PC card's firmware is referred to as CIS (Card Information Structure). It provides additional implementation details of the card. hwup checks the integrity of the card's built-in CIS and tries to load another CIS from disk if the card's CIS proves to be defective. The default setting is yes. To disable CIS loading from disk, set this variable to no.

PCMCIA_ALLOW_FUNC_MATCH

Linux device drivers contain a device ID table that tells drivers which devices to handle. This means that only those devices whose IDs are known to the kernel are supported. To support those cards whose ID is not listed, you can use function matching. This means that the driver is not selected by ID, but by the function of the card (such as a network card) and would be responsible for any PC card inserted with that function (such as network cards). The default setting is yes. To disable function matching, set this variable to no.

PCMCIA_COLDPLUG_REINSERT

Cards that have been inserted before booting sometimes fail to be detected. To prevent that, cause a soft eject and a soft insert of the card by setting PCMCIA_COLDPLUG_REINSERT to yes. The default setting is no.

31.2.3. Interface Setup

Depending on the card type, different interfaces are registered after initialization has been successfully completed. Interface registration is handled by udev's hotplug. For details on udev and hotplug, refer to Chapter 12, Dynamic Kernel Device Management with udev.