Chapter 26. PCMCIA

Contents

26.1. Controlling PCMCIA Cards Using pccardctl
26.2. PCMCIA in Detail
26.3. Troubleshooting

Abstract

PCMCIA is often used to refer the hardware itself, although the term originates from the organization that standardized all possible types of PC cards, the PC Memory Card International Association. In the beginning, PCMCIA only included PC cards (using a 16-bit bus like ISA cards), but later on CardBus cards (using a 32-bit bus) were included. A wide range of PCMCIA hardware is supported in Linux. Linux additionally includes tools for managing PCMCIA.

PCMCIA cards are mainly used in mobile computing for different purposes. Examples include:

Most of the card management is silently handled by udev and hotplug. When user interaction is required, you use the pccardctl command. For PCMCIA background information, refer to Section 26.2, “PCMCIA in Detail”. For details on pccardctl, refer to Section 26.1, “Controlling PCMCIA Cards Using pccardctl”.

26.1. Controlling PCMCIA Cards Using pccardctl

Card management is normally handled by udev and hotplug without requiring any user interaction at all. The command pccardctl offers manual control of the card in case the automated process does not work flawlessly.

The following is a list of the most important pccardctl commands. All commands must be executed as root:

pccardctl insert

If the card has not been detected automatically, notify the client drivers that the card has just been inserted.

pccardctl eject

Eject the card manually and notify the client drivers that it will be ejected. Cut power to the socket. This option is especially useful if you noticed problems with suspend and resume as described in Section 26.3.2, “General Suspend Issues with PCMCIA”.

pccardctl suspend

Shut down and disable power for a socket, but do not eject the card (unbind the appropriate modules).

pccardctl resume

Bring up power for the socket and restore the configuration from before the suspend event.

For further information, refer to the manual page of pccardctl.

26.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 26.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 26.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 26.2.3, “Interface Setup” for details on this.

26.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 26.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.

26.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.

26.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 21, Dynamic Kernel Device Management with udev.

26.3. Troubleshooting

The following is a list of the most prominent issues that are occasionally encountered with PCMCIA. More information about this is available in the PCMCIA README (/usr/share/doc/packages/pcmciautils/README.SuSE).

26.3.1. Machine Crashes on PCMCIA

Your machine crashes when PCMCIA is started on boot. To find out what caused your machine to crash, set it up manually as described below. In carefully setting up PCMCIA manually, you can clearly identify the step or component that crashed your machine. Once the culprit has been identified, you can circumvent the problematic step or component.

To manually set up PCMCIA, proceed as follows:

  1. Prevent PCMCIA from being started on system boot and enable option sysrq for easier debugging by appending the following options to the boot prompt:

    init=3 pcmcia=off sysrq=1

    For more information about sysrq, refer to /usr/src/linux/Documentation/sysrq.txt.

  2. Boot the system into a text-based environment and log in as root.

  3. Add the appropriate PCMCIA modules to the kernel:

    /sbin/modprobe yenta_socket
    /sbin/modprobe pcmcia
    
  4. Start the PCMCIA socket:

    /sbin/pcmcia-socket-startup N

    Replace N with the number of the socket. Repeat this step for each socket.

  5. If the previous step crashed your machine, this might have been caused by wrong I/O or memory ranges specified in /etc/pcmcia/config.opts. To prevent this, do one of the following:

    • Exclude ranges in /ect/pcmcia/config.opts and retry the socket setup.

    • Add the ranges manually as described below.

      After you successfully added the appropriate ranges manually, set them permanently by including them in /etc/pcmcia/config.opts.

  6. After the socket setup has been successfully completed, card initialization and interface setup work as described in Section 26.2.2, “Card Initialization” and Section 26.2.3, “Interface Setup”.

To manually add I/O ranges, proceed as follows (for each socket):

  1. Change into the directory that holds the range configurations (in this case, pcmcia_socket0, adapt for other socket numbers):

    cd /sys/class/pcmcia_socket/pcmcia_socket0
  2. Execute the following command:

    echo begin - end > available_resources_io

    Replace begin and end with the addresses where the new range should start and end. The correct values can only be determined by trial and error.

Manually adding the following ranges:

echo 0x800 - 0x8ff > available_resources_io
echo 0xc00 - 0xcff > available_resources_io

equals the following line from /etc/pcmcia/config.opts:

include port 0x800-0x8ff, port 0xc00 0xcff

The same procedure applies for the memory ranges under available_resources_mem.

[Important]Identifying Faulty Default Settings

If you find a faulty range in the default configuration file (/etc/pcmcia/config.opts) shipped with this product, file a bug against it in http://bugzilla.novell.com, so that developers can look into this issue.

26.3.2. General Suspend Issues with PCMCIA

Whenever suspending your system (suspend to disk, suspend to RAM, or standby), do not plug or unplug any hardware items while the system is in suspend mode. Otherwise, the system might not resume properly.

To automatically eject PCMCIA cards on suspend, proceed as follows:

  1. Log in as root.

  2. Open the file /etc/powersave/sleep.

  3. Set the following variables:

    SUSPEND2DISK_EJECT_PCMCIA="yes"
    SUSPEND2RAM_EJECT_PCMCIA="yes"
    STANDBY_EJECT_PCMCIA="yes"
    
  4. Save the file to apply your settings.

If additional modules need to be ejected on suspend, proceed as above and add the module names to the following variables:

UNLOAD_MODULES_BEFORE_SUSPEND2DISK=""
UNLOAD_MODULES_BEFORE_SUSPEND2RAM=""
UNLOAD_MODULES_BEFORE_STANDBY=""

For general information about the powersave daemon, refer to Section 28.5, “The powersave Package”.

26.3.3. For More Information

Find the latest up-to-date information about PCMCIA in /usr/share/doc/packages/pcmciautils/README.SuSE. For a comprehensive overview of PCMCIA hardware and its fields of use, turn to the official PCMCIA Web site (http://www.pcmcia.org/pccard.htm). To check whether a certain card or device is generally supported by Linux, refer to the Linux PCMCIA/CF/CardBus Card Survey at http://tuxmobil.org/pcmcia_linux.html.