Direct io memory access in Linux Kernel

Hi all,

I’m new to both Linux kernel but I need to do same development on the linux kernel on BBB. My kernel has the console on uart0(i.e., ttyO0). I enabled uart1 in the device tree and want to do some direct register access to it. I did echo "test" > /dev/ttyO1 and it works fine.Then I wrote a kernel module like this:

void *puart1 = ioremap(0x48022000, 4096); // remap the uart1 address
printk("%s: 0x%08lx → 0x%p\n", 0x48022000, 0xfa022000);

printk(“LSR:0x%08x\n”, (int)(puart1+0x14));

But the kernel opps at the last line:

[ 108.462047] 0x48022000 → 0xfa022000
[ 108.541026] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa022014

[ 108.549051] Internal error: : 1028 [#1] ARM
[ 108.553429] Modules linked in: vmm_linux(O+)
[ 108.557921] CPU: 0 Tainted: G O (3.8.13-mini-00694-gd24eda0-dirty #20)
[ 108.566048] PC is at vmm_entry+0x28/0x8c [vmm_linux]
[ 108.571253] LR is at vmm_entry+0x18/0x8c [vmm_linux]
[ 108.576455] pc : [] lr : [] psr: 20000013
[ 108.576455] sp : df011e60 ip : 00000000 fp : df011f58
[ 108.588471] r10: bf002000 r9 : 00000000 r8 : bf000538
[ 108.593942] r7 : 00000001 r6 : bf0004fc r5 : bf0004dc r4 : bf000638
[ 108.600774] r3 : fa022000 r2 : 20000093 r1 : 00000001 r0 : bf0003b6
[ 108.607608] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 108.615079] Control: 10c5387d Table: 9f354019 DAC: 00000015
[ 108.621093] Process insmod (pid: 107, stack limit = 0xdf010238)

Why a simple register access will oops the kernel? Is there any other thing I should do?

(I’m aware that maybe this is not the right list to ask. But if it is not, please let me know where this question should go, Thanks!)

I believe you only use ioremap for CPUs that have a separate IO address bus. The AM3358 IO is available on the same address bus as regular memory. Simply read and write to 0xFA0022000 + should work just fine. You might ask why the address is different to the UART1 defined in TRM. This is done in arch/arm/mach-omap2/iomap.h - simply use OMAP2_L4_IO_ADDRESS(0x48022000) to get 0xFA022000.


Oh damn. Simply disregard, I had some stupid filter on.