[PATCH 6/6] [WIP] libertas: add support for 8385 CompactFlash cards

Holger Schurig hs4233 at mail.mn-solutions.de
Tue Jun 19 11:47:33 EDT 2007


> > +static int if_cs_poll_reg(struct if_cs_card *card, uint 
addr, u8 reg)
> > +{
> > +     int i;
> > +
> > +     for (i = 0; i < 500; i++) {
> > +             u8 val = if_cs_read8(card, addr);
> > +             if (val == reg)
> > +                     return i;
> > +             udelay(100);
> > +     }
> > +     return -ETIME;
>
> Hmm; is it normal in CF drivers to poll the card a lot, or is
> this just 
> for test/debug for the time being?

Until I find a better programming idiom. Look in the firmware 
v5.1 manual, page 18, 3. e) and page 19, at the very top, point 
9. I didn't follow their timing exactly.

The polling actually only happens while programming the firmware, 
so for me getting it working was more important than 
over-optimizing.

Do you have suggestions for me?  This doesn't happen in interrupt 
context, so I guess I can sleep. Or I could transform this into 
a statemachine and let call back from the kernel, but this seems 
a bit complicated. Any ideas?

> > +#define IF_CS_H_STATUS			0x00000000
> > +#define IF_CS_H_STATUS_TX_OVER		0x01
> > +#define IF_CS_H_STATUS_RX_OVER		0x02
> > +#define IF_CS_H_STATUS_DNLD_OVER	0x04
> > +
> > +#define IF_CS_H_INT_CAUSE		0x00000002
> > +#define IF_CS_H_IC_TX_OVER		0x0001
> > +#define IF_CS_H_IC_RX_OVER		0x0002
> > +#define IF_CS_H_IC_DNLD_OVER		0x0004
> > +#define IF_CS_H_IC_HOST_EVENT		0x0008
> > +#define IF_CS_H_IC_MASK			0x001f
>
> These look a lot like the HIS_* defines above, are they the
> same?

Yes, you're right. I added them before I found the HIS_xxx 
defines in defs.h. At that time, my constants where hardware 
related, the other ones logical bits.

> Yeah, there seem to be a lot of these same constants floating
> around, it would be good to consolidate them all and just have
> two, I assume one for host bits and one for card bits, right?

Or even just one, if they are the same anyway.


> > +	/* "If the value is 0x5a, the firmware is already
> > +	 * downloaded successfully"
> > +	 */
> > +	if (scratch == 0x5a)
> > +		goto done;
> > +
> > +	/* "If the value is != 00, it is invalid value of register
> > */ +	if (scratch != 0x00) {
> > +		ret = -ENODEV;
> > +		goto done;
> > +	}
>
> Are the 0x5a and 0x00 values determined empirically?

No, see Firmware Specification v5.1, page 18.

> Also, 
> are the scratch registers part and interface dependent at all?
> The SDIO driver uses different values for "firmware ready"; I
> wouldn't expect them to be the same, but how similar are SDIO
> and CF?  They appear to use a lot of the same constructs and
> even constants.

For now, I don't care. I don't see that if_cs.c also contains 
code for SDIO, I much more see that a different if_sdio.c file 
get's written. Once that is done, we can look at what is equal 
and put that into a header file.


> One more quick question; does the device show up correctly in
> HAL as a child of the socket?  It should be Socket > Card >
> network interface I think.

What is HAL?  I don't know this software. However, in my /sys 
tree, I see some directories like this, so I guess it's properly 
put there:

./pci0000:00/0000:00:1e.0/0000:02:0b.0
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/net
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/net/eth1
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/net/eth1/power
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/net/eth1/wireless
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/net/eth1/statistics
./pci0000:00/0000:00:1e.0/0000:02:0b.0/0.0/power
./pci0000:00/0000:00:1e.0/0000:02:0b.0/pcmcia_socket
./pci0000:00/0000:00:1e.0/0000:02:0b.0/pcmcia_socket/pcmcia_socket0
./pci0000:00/0000:00:1e.0/0000:02:0b.0/pcmcia_socket/pcmcia_socket0/power
./pci0000:00/0000:00:1e.0/0000:02:0b.0/power




More information about the libertas-dev mailing list