[U-Boot] virt to phys mapping function

Kumar Gala galak at kernel.crashing.org
Thu Nov 20 20:11:40 CET 2008


In trying to get 36-bit physical working on 85xx I ran into an issue  
with the NAND driver.  Its given a virtual address and trying to match  
it to which chipselect it maps to.  The assumption in the code is that  
we have a 1:1 mapping and clearly that may not be true w/36-bit phys.

So it seems we need a virt_to_phys() function.  However there are a  
few questions I have about this:

1. what should the prototype of this function look like:

phys_addr_t virt_to_phys (void * addr);

or

int virt_to_phys(void *p, phys_addr_t *addr);

I think the vast majority of implementations will be just 1:1 mapping,  
however there is a question in a dynamic mapping case of how to report  
back not finding a mapping.

2. what impact is there on existing use on:

cpu/mips/au1x00_eth.c:	fifo_tx[next_tx].addr = (virt_to_phys(packet))| 
TX_DMA_ENABLE;
cpu/mips/au1x00_eth.c:		fifo_rx[next_rx].addr =  
(virt_to_phys(NetRxPackets[next_rx]))|RX_DMA_ENABLE;
cpu/mips/au1x00_eth.c:		fifo_tx[i].addr = virt_to_phys(&txbuf[0]);
cpu/mips/au1x00_eth.c:		fifo_rx[i].addr =  
(virt_to_phys(NetRxPackets[i]))|RX_DMA_ENABLE;

- k


More information about the U-Boot mailing list