I have a DM8148 running 2.6.37 Linux kernel.
I am trying to change pinmuxing from userspace program ran with root access.
I am able to read the pinmuxing but I can not write. Nothing errors out, it just doesn't change the value when I read it back.
My code is below, please help.
target = 0x48140B10; //Touch_int
target2 = 0x48140AF0; //Touch_rst
value = 0x00050080;
/* Map one page */
map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
if(map_base == (void *) -1) {
printf("Memory map failed.\n");
} else {
printf("Memory mapped at address %p.\n", map_base);
}
fflush(stdout);
virt_addr = map_base + target - (target & ~MAP_MASK);
virt_addr2 = map_base + target2 - (target2 & ~MAP_MASK);
/* acess remapped region here */
int read_result, read_result2, new_result, new_result2;
read_result = *((volatile unsigned long *) virt_addr);
read_result2 = *((volatile unsigned long *) virt_addr);
*((volatile unsigned long *) virt_addr) = value;
*((volatile unsigned long *) virt_addr2) = value;
msync(map_base, MAP_SIZE, MS_SYNC);
new_result = *((volatile unsigned long *) virt_addr);
new_result2 = *((volatile unsigned long *) virt_addr);
printf(" Was %08x , %08x\n", read_result, read_result2 );
printf(" Set to %08x , %08x\n", value, value);
printf("Now %08x, %08x\n", new_result, new_result2);