static I/O device mapping of UART for early prints & console
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) Below are the details #define PLAT_PHYS_OFFSET 0x50000000 (with 256 MB SDRAM) #define CONFIG_PAGE_OFFSET 0xc0000000 #define S3C_ADDR_BASE 0xF6000000 (virtual address for device registers) #define S3C_VA_UART (S3C_ADDR_BASE + (0x01000000) ) #define S3C_PA_UART 0x7F005000 (UART - Physical address) #define S3C_VA_UART 0xF7000000 (UART virtual address = 0xF6000000 + 0x01000000) I tried to calculate the virtual address by using " __phys_to_virt(x)" macro. #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET) from the above macro, I expect __phys_to_virt(S3C_PA_UART) = S3C_VA_UART = 0xF7000000 but if i do calc, 0x7F005000 - 0x50000000 + 0xc0000000 = 0xef005000 which is not correct. I think, i'm not using the correct macro for getting the virtual address for UART. can someone suggest how to do this calculation for getting proper virtual address for UART for the above configuration. Thanks, pcuser
Date: Sun, 11 Mar 2012 12:29:44 +0530 Subject: static I/O device mapping of UART for early prints & console From: pcuser.mails@gmail.com To: kernelnewbies@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.
participants (2)
-
pcuser p -
卜弋天