This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why I can't read General Purpose Timer's register value?

I am testing the pwm driver with am3517 to control the brightness, and one time I need to read timer11 tclr value. but when insmod it under  kernel 2.6.37 the kernel will crash, but the same procedure will work under kernel 2.6.32.

Technical Reference Manual - AM3517

-------------------------------------------------------------

General-Purpose Timers Register Manual www.ti.com
Table 13-28. TCLR
Address Offset 0x024
Physical Address 0x4831 8024 Instance GPT1
0x4903 2024 GPT2
0x4903 4024 GPT3
0x4903 6024 GPT4
0x4903 8024 GPT5
0x4903 A024 GPT6
0x4903 C024 GPT7
0x4903 E024 GPT8
0x4904 0024 GPT9
0x4808 6024 GPT10
0x4808 8024 GPT11
Description This register controls optional features specific to the timer functionality.
Type RW
-----------------------------

My test code:

5531.test_drv.c.txt

the crash log:

8228.insmod-crash-log.txt



  • Hi Kevin,

    You need yo enable interface clock before accessing timer module registers.

    Please make sure that interface clock is enabled.

    Regards,

    Pankaj Bharadiya

  • Hi Pankaj,

    Thiis time I add the clk_enable code to my test driver, my code is 

    5047.test_drv.c.txt

    and the error is still the same, did I enable the clock wrongly?  the log is 

    4540.enable-fclk-log.txt

    Thanks,

    Kevin

  • Hi Kevin,

    Please enable both functional and interface clock for GPT11.

    You can use devmem2 to enable and test.

    Here is what I have tried on AM37x board.

    1. Enable Functional clock. <Bit 12 , CM_FCLKEN1_CORE register >

    # devmem2 0x48004a00 w
    /dev/mem opened.
    Memory mapped at address 0x40120000.
    Value at address 0x48004A00 (0x40120a00): 0x6000

    # devmem2 0x48004a00 w  0x7000

    2. Enable Interface clock (BIT 12:  CM_ICLKEN1_CORE register)

    # devmem2 0x48004a10 w
    /dev/mem opened.
    Memory mapped at address 0x4013e000.
    Value at address 0x48004A10 (0x4013ea10): 0x303E052

    # devmem2 0x48004a10 w 0x303F052
    /dev/mem opened.
    Memory mapped at address 0x40223000.
    Value at address 0x48004A10 (0x40223a10): 0x303E052
    Written 0x303F052; readback 0x303F052

    3. Test GPT11 Read using devmem2

    # devmem2 0x48088024  w
    /dev/mem opened.
    Memory mapped at address 0x40061000.
    Value at address 0x48088024 (0x40061024): 0x0

    # lsmod
    wl12xx 125411 0 - Live 0xbf0b1000
    mac80211 191033 1 wl12xx, Live 0xbf071000
    omaplfb 10798 0 - Live 0xbf069000
    cfg80211 134778 2 wl12xx,mac80211, Live 0xbf038000
    pvrsrvkm 154142 31 omaplfb, Live 0xbf007000
    compat 3717 1 mac80211, Live 0xbf000000

    4. Load your module (Commented clock code as clocks are enabled using devmem2 utility)

    # insmod test.ko
    [  385.462005] -----------------test_drv_init-enable clk--------------------
    [  385.469146] virt_base = fa088000
    [  385.472503] tclr = 21

    Reards,

    Pankaj Bharadiya



  • I want to generate  pulses on GPTimer11. But I am not able to generate it. could  you give me an example ,many thanks

  • @Pankaj

    Thanks!  Great explanation and (finally) made me read the PRCM chapter of the reference manual.  Now I understand the need for the functional and interface clocks.

    Dave

  • Hello Pankaj

    I was trying to boot an elf image through kexec(without uboot) on BeagleBoard xM(omap 3530).

    During booting process, a function is used to intialize timer which tries to use  GPTIMER 11 registers

    and when it tries to access registers an error message comes (KERNEL DATA ABORT!).

    It will be very helpful if you could help.

    Urgent

  • HI Abhishek,

    Please do GPT11 inferface clock and functional clock from your board file and try

    Please send boot log to debug this further.

    Regards,

    Pankaj Bharadiya

     

  • Hi Pankaj

    I am trying boot secure embedded L4 thorough kexec(without uboot).

    The elf image does have a elfloader which enables mmu, paging etc.

    which then loads kernel image.

    This is the message I am getting while booting on BeagleBoard xM:

    # kexec -l wombat-image-arm-omap3
    In ELF ARM PROBE[   36.734741] Start Address = 0x82000110

    In ARM ELF LOAD
    # kexec -e                       
    [   40.768890] Starting new kernel
    [   40.772308] Start Address = 82000110
    [   40.776062] Bye!
    ELF-loader image started:   paddr=[0x82000110..0x82754000]
    ELF-loading kernel image:   paddr=[0x80000000..0x8002c000] vaddr=[0xf0000000..0xf002c000] v_entry=0xf0002f9c
    ELF-loading userland image: paddr=[0x80cff000..0x814f5000] vaddr=[0x009ff000..0x011f5000] v_entry=0x00a00000
    Enabling MMU and paging
    Jumping to kernel-image entry point
    Bootstrapping kernel


    KERNEL DATA ABORT!
    Faulting instruction: 0xf0000170
    DSFR: 0x1008
    FAR: 0xfff03014 DFSR: 0x1008
    halting...

    This is the function which when called produces an error:

    init_timer(void)
    {
        int timeout;

        timer->cfg = TIOCP_CFG_SOFTRESET;

        for(timeout = 10000; !timer->tistat && timeout > 0; timeout--)
            ;
        if(!timeout)
            return;

        maskInterrupt(/*disable*/ true, GPTIMER11_IRQ);

        // Set the reload value
        timer->tldr = 0xFFFFFFFFUL - TIMER_INTERVAL_TICKS;

        // Enables interrupt on overflow
        timer->tier = TIER_OVERFLOWENABLE;

        // Clear the read register
        timer->tcrr = 0xFFFFFFFFUL - TIMER_INTERVAL_TICKS;

        // Set autoreload and start the timer
        timer->tclr = TCLR_AUTORELOAD | TCLR_STARTTIMER;
    }

  • timer->cfg = TIOCP_CFG_SOFTRESET; // This one working

        for(timeout = 10000; !timer->tistat && timeout > 0; timeout--) // not able to read timer->tistat

  • hii pankaj

    can you tell me which refrence manual you referred, i am also going to start with timers.

    thanx