I am trying to read the global system timer for Cortex A9, OMAP 4430 architecture (pandaboard rev A6). I work directly on the board with Debian GNU/Linux 7 (wheezy) and 3.9.11-x5 kernel version.
In general, my aim is to read values of the main system counter, which Linux system call invokes (e.g. clock_gettime()). I know that there are several timers in OMAP 4430 and I have to figure out which exact timer and register is used by Linux system call. I used this OMAP 4430 TRM where is said that register of "global timer" has this base address 0x48240600 with offset 0x200. Is it correct address for system timer? Now when I try to map and read this addresses, I always get 0 and it seems to me that something is wrong. I also have already tried to maped and read each of 11 GPtimers registers and I received either zero or bus error or like in case of GPTimer1 just random constant value which is not incrementing.
Earlier I could managed the same issue with beaglebone board (AM335x architecture, Cortex A8). I concluded that this "main" system timer addresses to 24MHz clock and DMTimer2 register. As I understood, the Linux kernel already contains dmtimer driver, which allows using system time through accessing to this DMTimer2 register. I maped its address 0x48040000 with offset of 0x3c and simply get ticks value. So I hoped that the idea of reading the timer would be the same for Cortex A9, but so far I fail. That's way I am asking, may be there are some additional tricks of reading this register for OMAP 4430?
To be more precise, this is the way how I read counter:
#define MAP_SIZE 4096UL #define MAP_MASK (MAP_SIZE - 1) volatile unsigned char* gpt_regs; constexpr uint32_t GPTimer = 0x48240600; constexpr uint32_t offset = 0x200; int32_t fd; if ( (fd=open("/dev/mem", O_RDWR|O_SYNC) ) < 0) { perror("open"); exit(-1); } gpt_regs = (unsigned char*) mmap(0, MAP_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, GPTimer & ~MAP_MASK); uint32_t counter1 = * (int32_t*) ( gpt_regs + offset);
I will appreciate any help.