Successfully developed IO/Memory card driver

  • Gary Davies
    Gary Davies

    Without any Linux or driver development experience I successfully developed a driver for a PCMCIA comms card.

    I cannot name the company or card so don't ask me about either.

    Downloaded the Linux Card Services Programmers Guide and read it many times.
    Installed Red Hat Linux 2.2.16-22 and configured the display, network card, printer (lost my Windows 200 partition ahhhhhhh).
    Installed the Card Services package 3.1.25
    Built the dummy_cs driver used it as a template for my card driver
    Bought the book "The PC Card Software Developer's Handbook" which helped a lot (code can be downloaded from ftp site).
    Successfully requested an I/O address 0x100
    Successfully requested an IRQ 3 (Same as com port but worked fine)
    Successfully requested two memory windows
    Successfully ioremapped the two windows into Kernel memory

    Bought the Beginning Linux Programming book and wrote a char driver developing some Linux IOCTL and fops skills.

    Added IOCTL (fops) functions to my driver
    Added vma functions
    Got frustrated and tried the driver on my laptop and read the CIS for the first time!!!!  Huge leap forward.  The first development machine card reader wasn't working properly.  That was a terrible revelation.  Continued development on my laptop

    Worked on the CIS.  Read manfid, config, IRQ list, window sizes etc
    Changed the driver to configure according to CIS.
    Had so much trouble reading writing ioremapped memory!!!!!
    Successfully read/wrote to card memory from within the driver, that was an amazing day!
    Successfully read/wrote to the card memory from within a user mode app using a library interfacing with the driver.
    Updated the existing PCI Linux library to use my new PCMCIA driver.
    Debugged the new Library code using sample apps until all test succeeded.

    The main reason for this communication is provide developers with an opportunity to ask me Linux Card Services questions.  I am not a guru but I am willing to pass on any information, experience, tips, code etc.

    regards Gary Davies

    • Ajit Kumar
      Ajit Kumar

      We are using PCI1520 which is sitting on PCI Bus 1 of Marvell System controller to interface compactflash card.
      Below is our configuration:
      Status Command reg(0x04) = 0xA100003
      CardBus socket/ExCA base address(0x10) = 0xF4220000
      CardBus Memory base register 0(0x1c) = 0xF4230000 and
      CardBus Memory limit register 0(0x20) = 0xF4238000
      CardBus I/O base register 0(0x2c) = 0xD0000000
      CardBus I/O limit register 0(0x30) = 0xD0008000
      System control(0x80) = 0x8443000
      So PCI1520 ExCA Registers are at: 0xF4220800 (config space offset 0x10 has the value 0xF4220000)
      ExCA Config is below:
      ExCA Address Window Enable Register(0x806) = 0xC1
      ExCA I/O Window Control Register(0x807) = 0x22

      With this configuration Card detection is happening properly and socket is powered up.
      Now we are not able to map the Compactflash memory(Both Attribute  and Common memory)
      1.What is the significance of ExCA regs at
          0x808 to 0x80F (I/O Windows)
          0x836 to 0x839 (I/O Windows)
          0x810 to 0x835 (Mem Windows)
          0x840 to 0x844 (Mem Windows)   
      2.We are not sure what values to be filled in the above ExCA regs to access the compactFlash card memory.
      Product is in release phase, we are struck up with these.
      Please help on these issues.

      Thanks in advance