Need help with PCMCIA client driver

Need help with PCMCIA client driver

Post by R » Thu, 13 Jun 2002 04:32:03



Hello all
I am a Linux newbie in the process of trying to write a pcmcia client
driver for our hardware - to work on RedHat v7.1.
The card requires 2 memory windows, 1 for attribute memory and 1 for
common memory, mapped to the host address space. It does not use any
interrupts or IO windows.

Following the client examples - I have written a basic module with
just the attach, detach, eventhandler, config functions. I then
modifed /etc/pcmcia/config.opts to load the module I compiled.

In the card config routine I do the following :

read the CISTPL_CFTABLE_ENTRY
CardServices(RequestConfiguration)      

***
*** the cards cistpl_ctable_entry does not have any memory window
information ***
- so I set up a cistpl_cftable_entry_t dflt entry and fill it in as
follows :

        dflt.mem.nwin = 2;
        dflt.mem.win[0].len = 0x1000;   /* 4K attribute mem window */
        dflt.mem.win[0].card_addr = 0;  /* address in card memory space */
        dflt.mem.win[0].host_addr = 0;  /* arbitrary in host */

        dflt.mem.win[1].card_addr = 0x0;
        dflt.mem.win[1].host_addr = 0;  /* 0 = arbitrary */
        dflt.mem.win[1].len = 0x8000;   /* 32K cmn memory window */

- foll. card services Calls are then made to map attribute memory
window

        mem = &dflt.mem;

        /* MAP Attribute memory to host address space */
        req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE;
        req.Base = mem->win[0].host_addr;
        req.Size = mem->win[0].len;
        req.AccessSpeed = 0;

        link->win = (window_handle_t)link->handle;
        CFG_CHECK(RequestWindow, &link->win, &req);
        printk(KERN_DEBUG ".. RequestWindow attr mem window 0... done.
Base Addr = %lx, Size = %lx\n", (u_long)req.Base, (u_long)req.Size);

        mapAttr.Page = 0;
        mapAttr.CardOffset = mem->win[0].card_addr;
        CFG_CHECK(MapMemPage, link->win, &mapAttr);
        printk(KERN_DEBUG ".. MapMemPage mem window 0...done\n");

        /* Map it to virtual space */
        localInfo->attrBase = (u32) ioremap(req.Base, req.Size);
        if (localInfo->attrBase)
        {
          localInfo->attrSize = req.Size;
          printk(KERN_DEBUG "Attr mem mapped to %lx\n", localInfo->attrBase);
        }
        else
          goto cs_failed;

- Process is then repeated to map the common memory window

- All of the above calls succeed with windows assigned as a0001000,
a0002000
with ioremap returning addresses cad42000, cad4d000 for attrib & cmn
memory resp.

At the end of it all in the config function, I try to do a test read
of Attribute & common memory using readb,  memcpy_toio etc. from the
addresses return by ioremap. as follows :
for (....)
{
  testR = readb(localInfo->attrBase+i);                      
  printk(KERN_DEBUG "Addr: %lx, Data %0x\n",
(u_long)localInfo->attrBase + i, testR);

Quote:}

*********************
**** PROBLEM ******
*********************

The data printed from the read of attribute memory - looks nothing
like the tuple data I expect to see read.
I also write some known values to the first x bytes of common memory.
However, the data printed from the read of common memory is not what I
wrote to it.

- It doesnt look like I am accessing the actual card memory. Is my
RequestWindow call even getting mapped to actual card memory ?

- Is the readb/memcpy_toio etc. an incorrect way of accessing card
memory ??

- Do I have to do a replace CIS to get the memory windows I need
mapped to the card correctly ?

Any help would be greatly appreciated.

Thanks
--radha

 
 
 

Need help with PCMCIA client driver

Post by dhind » Sat, 15 Jun 2002 04:51:15



Quote:> - It doesnt look like I am accessing the actual card memory. Is my
> RequestWindow call even getting mapped to actual card memory ?

At a glance it looks ok to me.

Quote:> - Is the readb/memcpy_toio etc. an incorrect way of accessing card
> memory ??

No that should work fine.

Quote:> - Do I have to do a replace CIS to get the memory windows I need
> mapped to the card correctly ?

No; the mapping does not depend on having a consistent CIS.

-- Dave