static I/O device mapping of UART for early prints & console

卜弋天 buyit at live.cn
Sun Mar 11 08:06:39 EDT 2012



 > Date: Sun, 11 Mar 2012 12:29:44 +0530
> Subject: static I/O device mapping of UART for early prints & console
> From: pcuser.mails at gmail.com
> To: kernelnewbies at kernelnewbies.org
> 
> I'm doing kernel porting to arm926 based FPGA board (similar to
> samsung-s3c6410 board). I'm trying to setup UART for early print and
> console.
> I gone through some reference boards(samsung-s3c6410) for setting up
> uart for early print & console.
> 
> I can't trace the virtual mapping for UART registers in "adduart"
> macro in "debug-macro.S" file
> 
> .macro addruart, rp, rv
>  ldr     \rp, = S3C_PA_UART
>  ldr     \rv, = S3C_VA_UART
> 
> 
> Basically,I want to know how to calculate this virtual
> address(S3C_VA_UART)  from the physical address(S3C_PA_UART)
actually, this is io_virtual_address map to io_physical_address, it is not equal to kernel_virtual_adressmap to kernel_physical_address.differenct platform providers such as Qualcomm, TI, STE, Samsung use different fomula to map IO address. for example, for OMAP1, TI use a very simple fomula to map from io_virtual_address to io_physical_address:io_virtual_address = io_physical_address-0x01000000 so suppose TI's uart0 physical address is 0xFFFB0000, then the virtial address of uart0 is 0xFEFB0000. for Samsung S3c64XX: 1. both physical and virtual address of uart is defined in map.h:#define S3C_PA_UART  (0x7F005000)
/* See notes on UART VA mapping in debug-macro.S */
#define S3C_VA_UARTx(x) (S3C_VA_UART + (S3C_PA_UART & 0xfffff) + ((x) * S3C_UART_OFFSET))#define S3C_VA_UART0  S3C_VA_UARTx(0)
#define S3C_VA_UART1  S3C_VA_UARTx(1)
#define S3C_VA_UART2  S3C_VA_UARTx(2)
#define S3C_VA_UART3  S3C_VA_UARTx(3) 2. so for uart0, the virtual address will be:virtual_uart0_address = S3C_VA_UART + (S3C_PA_UART & 0xfffff) and in map-base.h:#define S3C_ADDR_BASE (0xF4000000)
#define S3C_VA_UART S3C_ADDR(0x01000000) /* UART */
so S3C_VA_UART = 0xF5000000 3. at last:virtual_uart0_address = S3C_VA_UART + (S3C_PA_UART & 0xfffff)= 0xF5000000 + (0x7F005000&0xfffff) = 0xF5005000 
please do not try to use  __phys_to_virt, this is for kernel virtual address to kernel physical address translation, rather than IO address map.   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120311/05af489e/attachment.html 


More information about the Kernelnewbies mailing list