Subject: Re: Cardbus BAR Mapping questions/PCI differences
To: Phil Quinton <pquinton@softhome.net>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 03/14/2006 10:30:00
Phil Quinton wrote:
> Hi,
>
>  Just a couple of questions.
>
>  I'm having another bash at porting the satalink driver to cardbus and 
> I've noticed a couple of diffences that I could do with being cleared 
> up...
>
> Below is a code snippet from dev/cardbus/if_ath_cardbus.c. My question 
> is this:
>
> When the BAR (ATH_PCI_MMBA) is mapped, the &adr is OR'd with 
> CARDBUS_MAPREG_TYPE_MEM and the written back with a Cardbus_conf_write 
> later on.
>
> Why? And does this need to be done with ALL BAR's that need to be 
> mapped?
>   
This a bit in the mapping register that determines whether the mapping
is for IO space or memory space.

I'm surprised that the "ath" driver has to know about this detail though
-- it should be handled automatically as part of Cardbus_mapreg_map.

> The reason I ask is the satalink driver maps BAR5 for it's chipset and 
> BAR4 is mapped later on for the IDE portion and the drivers in 
> drv/cardbus only seem to need to map one BAR.
>   
Which bars to map, and how many, are necessarily device specific.

    -- Garrett
> Thanks in advance,
> Phil.
>
> ---SNIP---
> /*
>  * Map the device.
>  */
> if (Cardbus_mapreg_map(ct, ATH_PCI_MMBA, CARDBUS_MAPREG_TYPE_MEM, 0,
> 	    &sc->sc_st, &sc->sc_sh, &adr, &csc->sc_mapsize) == 0) {
> #if rbus
> #else
> 		(*ct->ct_cf->cardbus_mem_open)(cc, 0, adr, adr+csc->
> sc_mapsize);
> #endif
> 		csc->sc_bar_val = adr | CARDBUS_MAPREG_TYPE_MEM;
> 	}
>
> 	else {
> 		printf("%s: unable to map device registers\n",
> 		    sc->sc_dev.dv_xname);
> 		return;
> 	}
> ---SNIP---
>
> ... later on ....
>
> ---SNIP---
> 	/* Program the BAR. */
> 	cardbus_conf_write(cc, cf, csc->sc_tag, ATH_PCI_MMBA,
> 	    csc->sc_bar_val);
> ---SNIP---
>
>   


-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191