CPM timers in MPC8260 - Linux

This is a discussion on CPM timers in MPC8260 - Linux ; Hi all We have a requirement where we need to run a 1 millisecond timer in the kernel space . The processor we are using is MPC8260 . I am thinking of accessing the CPM timers of MPC 8260 which ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: CPM timers in MPC8260

  1. CPM timers in MPC8260

    Hi all

    We have a requirement where we need to run a 1 millisecond timer in the
    kernel space .
    The processor we are using is MPC8260 . I am thinking of accessing the
    CPM timers of MPC 8260 which provides a least resolution of
    16-nanosecond to maximum resolution of 4 seconds.

    I have written a sample code .

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

    #define CPMTIMER_TGCR_GM1 0x0008 /* gate mode */
    #define CPMTIMER_TGCR_FRZ1 0x0004 /* freeze timer */
    #define CPMTIMER_TGCR_STP1 0x0002 /* stop timer */
    #define CPMTIMER_TGCR_RST1 0x0001 /* restart timer */
    #define CPMTIMER_TGCR_CAS2 0x80 /* cascade timer */

    #define CPMTIMER_TMR_ORI 0x0010 /* output reference interrupt
    enable */
    #define CPMTIMER_TMR_FRR 0x0008 /* free run/restart */
    #define CPMTIMER_TMR_ICLK_INT16 0x0004 /* source internal clock/16 */
    #define CPMTIMER_TMR_ICLK_INT 0x0002 /* source internal clock */






    volatile immap_t *immap = (immap_t *)IMAP_ADDR;

    void my_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    {
    // do some processing here
    }


    int __init device_init(void)
    {
    unsigned int count = 0;

    bd_t *bd = (bd_t *)__res;


    count = (bd->bi_intfreq) / (16 * 1000)


    immap->im_cpmtimer.cpmt_tgcr1 &= ~(CPMTIMER_TGCR_CAS2|
    CPMTIMER_TGCR_GM1 |
    CPMTIMER_TGCR_RST1|
    CPMTIMER_TGCR_FRZ1|
    CPMTIMER_TGCR_STP1);


    immap->im_cpmtimer.cpmt_tmr1 =
    CPMTIMER_TMR_ORI |
    CPMTIMER_TMR_FRR | CPMTIMER_TMR_ICLK_INT16;

    immap->im_cpmtimer.cpmt_trr1 = count;
    immap->im_cpmtimer.cpmt_tcr1 = 0;
    immap->im_cpmtimer.cpmt_tcn1 = 0;
    immap->im_cpmtimer.cpmt_ter1 = 0;

    /* set up interrupt handler */
    if(request_irq(SIU_INT_TIMER1,
    my_timer_interrupt,
    SA_INTERRUPT,
    "timer_handler",
    NULL) < 0)
    {
    printk(KERN_INFO "unable to start the interrupt handler \n");

    }

    /* and start timer */
    immap->im_cpmtimer.cpmt_tgcr1 |= CPMTIMER_TGCR_RST1;


    return 0;
    }

    void cleanup_device(void)
    {

    immap->im_cpmtimer.cpmt_ter1 = 0xffff;

    request_irq(SIU_INT_TIMER1, NULL, 0, 0,
    0);

    printk(KERN_INFO "cleaned up \n");
    }

    module_init(device_init);
    module_exit(cleanup_device);


    MODULE_LICENSE("GPL");

    MODULE_AUTHOR("");
    MODULE_DESCRIPTION("driver code");

    EXPORT_NO_SYMBOLS;
    ----------------------------------------------------------------------------------------------------------------------------------------

    When I downloaded this kernel module into the target , and did a
    insmod of the kernel module , the target hangs .

    Can anyone tell me what is the problem with the code ?


    Regards
    Morphics


  2. Re: CPM timers in MPC8260

    On Tue, 13 Jun 2006 06:17:47 -0700, Morphics wrote:

    > void my_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    > {
    > // do some processing here
    > }


    > When I downloaded this kernel module into the target , and did a
    > insmod of the kernel module , the target hangs .


    You have to deactivate the interrupt inside the handler, duh.

    Also, since you're having trouble with basics, don't use SA_INTERRUPT.
    You only need a millisecond resolution, and 8260 clocks what... 133MHz?
    I don't see you benefiting from the complication of SA_INTERRUPT.

    -- Pete


  3. Re: CPM timers in MPC8260

    Thanks a lot

    i cleared the interrupts inside the handler and it worked

    Morphics


    Pete Zaitcev wrote:
    > On Tue, 13 Jun 2006 06:17:47 -0700, Morphics wrote:
    >
    > > void my_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    > > {
    > > // do some processing here
    > > }

    >
    > > When I downloaded this kernel module into the target , and did a
    > > insmod of the kernel module , the target hangs .

    >
    > You have to deactivate the interrupt inside the handler, duh.
    >
    > Also, since you're having trouble with basics, don't use SA_INTERRUPT.
    > You only need a millisecond resolution, and 8260 clocks what... 133MHz?
    > I don't see you benefiting from the complication of SA_INTERRUPT.
    >
    > -- Pete



+ Reply to Thread