<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<br> <BR><div id="SkyDrivePlaceholder"></div><div>> Date: Sun, 11 Mar 2012 12:29:44 +0530<br>> Subject: static I/O device mapping of UART for early prints & console<br>> From: pcuser.mails@gmail.com<br>> To: kernelnewbies@kernelnewbies.org<br>> <br>> I'm doing kernel porting to arm926 based FPGA board (similar to<br>> samsung-s3c6410 board). I'm trying to setup UART for early print and<br>> console.<br>> I gone through some reference boards(samsung-s3c6410) for setting up<br>> uart for early print & console.<br>> <br>> I can't trace the virtual mapping for UART registers in "adduart"<br>> macro in "debug-macro.S" file<br>> <br>> .macro addruart, rp, rv<br>> ldr \rp, = S3C_PA_UART<br>> ldr \rv, = S3C_VA_UART<br>> <br>> <br>> Basically,I want to know how to calculate this virtual<br>> address(S3C_VA_UART) from the physical address(S3C_PA_UART)<br></div><div>actually, this is io_virtual_address map to io_physical_address, it is not equal to kernel_virtual_adress</div><div>map to kernel_physical_address.</div><div>differenct platform providers such as Qualcomm, TI, STE, Samsung use different fomula to map IO </div><div>address. </div><div>for example, for OMAP1, TI use a very simple fomula to map from io_virtual_address to io_physical_address:</div><div>io_virtual_address = io_physical_address-0x01000000</div><div> </div><div>so suppose TI's uart0 physical address is 0xFFFB0000, then the virtial address of uart0 is 0xF<font color="#ff0000">E</font>FB0000.</div><div> </div><div>for Samsung S3c64XX:</div><div> </div><div>1. both physical and virtual address of uart is defined in map.h:</div><div>#define S3C_PA_UART (0x7F005000)<br></div><div>/* See notes on UART VA mapping in debug-macro.S */<br>#define S3C_VA_UARTx(x) (S3C_VA_UART + (S3C_PA_UART & 0xfffff) + ((x) * S3C_UART_OFFSET))</div><div>#define S3C_VA_UART0 S3C_VA_UARTx(0)<br>#define S3C_VA_UART1 S3C_VA_UARTx(1)<br>#define S3C_VA_UART2 S3C_VA_UARTx(2)<br>#define S3C_VA_UART3 S3C_VA_UARTx(3)</div><div> </div><div>2. so for uart0, the virtual address will be:</div><div>virtual_uart0_address = S3C_VA_UART + (S3C_PA_UART & 0xfffff)</div><div> </div><div>and in map-base.h:</div><div>#define S3C_ADDR_BASE (0xF4000000)<br>#define S3C_VA_UART S3C_ADDR(0x01000000) /* UART */<br></div><div>so S3C_VA_UART = 0xF5000000</div><div> </div><div>3. at last:</div><div>virtual_uart0_address = S3C_VA_UART + (S3C_PA_UART & 0xfffff)</div><div>= 0xF5000000 + (0x7F005000&0xfffff) = 0xF5005000</div><div> </div><div><br>please do not try to use __phys_to_virt, this is for kernel virtual address to kernel physical address translation, </div><div>rather than IO address map.</div><div> </div><div> </div>                                            </div></body>
</html>