Skip to contentSkip to conversation

Interrupt-problem mpc5200

DISCUSSION S. Fricke 2 participants 5 messages Sep 10, 2007 – Sep 12, 2007

lore
Share & tools
lore

S. Fricke

author
#0 lore raw

Hello all.

What are the steps to configure an MPC500B-Board to react on an IRQ (2)?

I have written a test-driver with this code-snippets, but the prozessor hangs when loading the driver.

my __init-function looks like:

static int __init mod_init( void )

{
    volatile static struct mpc52xx_intr __iomem *intr;
    u32 intr_ctrl;

    // ...

    printk( "intmod.ko: interrupt init ");
    if (request_irq(MPC52xx_IRQ2, intmod_isr, IRQF_SHARED , "intmod",
                INTMOD_IRQ_BOARD) == -EBUSY)
        printk("KO\n");
    else
        printk("OK\n");

    intr = ioremap(MPC52xx_MBAR+MPC52xx_INTR_OFFSET, MPC52xx_INTR_SIZE);

    // read - modify - write
    intr_ctrl = in_be32(&intr->ctrl);
    intr_ctrl &= 0xfff3ffff;
    intr_ctrl |= 0x00080200;
    out_be32(&intr->ctrl, intr_ctrl);       // ERROR!

    if(intr) iounmap(intr);

    // ...
}

On the Line, marked with "ERROR!" the prozessor hangs and the kernel drops out.

TIA: Silvio

Mit freundlichen Gruessen
Silvio Fricke

Signature · 4 lines
-- S. Fricke ----------------------------- MAILTO:[email protected] --
   Diplom-Informatiker (FH)
   Linux-Entwicklung                       JABBER:      [email protected]
----------------------------------------------------------------------------
author
#1 lore raw

Dear Linux-enthusiasts,

I'm still at the same problem.

I have now implemented a irq_chip for the hardwired IRQ2. Now I have

--==>
volatile static struct mpc52xx_intr __iomem *intr; unsigned long flags;
static DEFINE_SPINLOCK(my_irq_controller_lock);

/*
* HELPER-Function
*/
static inline void io_be_setbit(u32 __iomem *addr, int bitno)

{
    out_be32(addr, in_be32(addr) | (1 << bitno));
}

static inline void io_be_clrbit(u32 __iomem *addr, int bitno)

{
    out_be32(addr, in_be32(addr) & ~(1 << bitno));
}

/*
* IRQ-Zeugs
*/
static void my_irq_ack(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_setbit(&intr->ctrl, 25);
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

/* irq - disabled */
static void my_irq_mask(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_clrbit(&intr->ctrl, 9); 
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

/* irq - enable */
static void my_irq_unmask(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_setbit(&intr->ctrl, 9);
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

static struct irq_chip my_irq_chip = {

    .typename   = "MY_IRQ_TEST",
    .ack        = my_irq_ack,
    .mask       = my_irq_mask,
    .unmask     = my_irq_unmask,

};

static int __init mod_init( void )

{
    // ...

    intr = mpc52xx_find_and_map("mpc52xx-pic");
    if(!intr) {
        panic(__FILE__ ": mpc52xx-pic - MAP failed");
    }

    set_irq_chip(MPC52xx_IRQ2, &my_irq_chip);
    a = request_irq(2, intmod_isr, IRQF_DISABLED , "intmod", INTMOD_IRQ_BOARD);
    printk("a: 0x%08x\n", a);

    // ...
}

<==--

Now my code hangs on the my_irq_unmask(...)-function on "io_be_setbit". Why? Can anyone help me, or point me to the right newsgroup/forum?

So long!

Silvio

Signature · 4 lines
-- S. Fricke ----------------------------- MAILTO:[email protected] --
   Diplom-Informatiker (FH)
   Linux-Entwicklung                       JABBER:      [email protected]
----------------------------------------------------------------------------
#2 lore raw

Is it possible the interrupt is going off as soon as you unmask it? Can you show your "intmod_isr".
I had a similar problem when I pulled a "wittrock" and forgot to make the interrupt edge sensitive, but from what I can see you have made yours edge sensitive.

-WITTROCK

Quoted 111 lines · S. Fricke

Dear Linux-enthusiasts,

I'm still at the same problem.

I have now implemented a irq_chip for the hardwired IRQ2. Now I have

--==>
volatile static struct mpc52xx_intr __iomem *intr; unsigned long flags;
static DEFINE_SPINLOCK(my_irq_controller_lock);

/*
* HELPER-Function
*/
static inline void io_be_setbit(u32 __iomem *addr, int bitno)

{
    out_be32(addr, in_be32(addr) | (1 << bitno));
}

static inline void io_be_clrbit(u32 __iomem *addr, int bitno)

{
    out_be32(addr, in_be32(addr) & ~(1 << bitno));
}

/*
* IRQ-Zeugs
*/
static void my_irq_ack(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_setbit(&intr->ctrl, 25);
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

/* irq - disabled */
static void my_irq_mask(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_clrbit(&intr->ctrl, 9); 
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

/* irq - enable */
static void my_irq_unmask(unsigned int irq)

{
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
    spin_lock_irqsave(&my_irq_controller_lock, flags);
    if(intr)
        io_be_setbit(&intr->ctrl, 9);
    spin_unlock_irqrestore(&my_irq_controller_lock, flags);
    printk("%s(%s/%d):\n", __FILE__, __FUNCTION__, __LINE__);
}

static struct irq_chip my_irq_chip = {

    .typename   = "MY_IRQ_TEST",
    .ack        = my_irq_ack,
    .mask       = my_irq_mask,
    .unmask     = my_irq_unmask,

};

static int __init mod_init( void )

{
    // ...

    intr = mpc52xx_find_and_map("mpc52xx-pic");
    if(!intr) {
        panic(__FILE__ ": mpc52xx-pic - MAP failed");
    }

    set_irq_chip(MPC52xx_IRQ2, &my_irq_chip);
    a = request_irq(2, intmod_isr, IRQF_DISABLED , "intmod",
INTMOD_IRQ_BOARD);
    printk("a: 0x%08x\n", a);

    // ...
}

<==--

Now my code hangs on the my_irq_unmask(...)-function on "io_be_setbit". Why?
Can anyone help me, or point me to the right newsgroup/forum?

So long!

Silvio

Signature · 12 lines
-- S. Fricke ----------------------------- MAILTO:[email protected]
--
   Diplom-Informatiker (FH)
   Linux-Entwicklung                       JABBER:      [email protected]
----------------------------------------------------------------------------


 
_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
Signature · 2 lines
View this message in context: http://www.nabble.com/Interrupt-problem-mpc5200-tf4413834.html#a12626802
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
#3 lore raw
In reply to S. Fricke

Hello,

Is it possible that this call failed?
intr = ioremap(MPC52xx_MBAR+MPC52xx_INTR_OFFSET, MPC52xx_INTR_SIZE);

Maybe intr is invalid at this point?
out_be32(&intr->ctrl, intr_ctrl); // ERROR!

Regards,
WITTROCK

Quoted 60 lines · S. Fricke

Hello all.

What are the steps to configure an MPC500B-Board to react on an IRQ (2)?

I have written a test-driver with this code-snippets, but the prozessor hangs when loading the driver.

my __init-function looks like:

static int __init mod_init( void )

{
    volatile static struct mpc52xx_intr __iomem *intr;
    u32 intr_ctrl;

    // ...

    printk( "intmod.ko: interrupt init ");
    if (request_irq(MPC52xx_IRQ2, intmod_isr, IRQF_SHARED , "intmod",
                INTMOD_IRQ_BOARD) == -EBUSY)
        printk("KO\n");
    else
        printk("OK\n");

    intr = ioremap(MPC52xx_MBAR+MPC52xx_INTR_OFFSET, MPC52xx_INTR_SIZE);

    // read - modify - write
    intr_ctrl = in_be32(&intr->ctrl);
    intr_ctrl &= 0xfff3ffff;
    intr_ctrl |= 0x00080200;
    out_be32(&intr->ctrl, intr_ctrl);       // ERROR!

    if(intr) iounmap(intr);

    // ...
}

On the Line, marked with "ERROR!" the prozessor hangs and the kernel drops out.

TIA: Silvio

Mit freundlichen Gruessen
Silvio Fricke

Signature · 12 lines
-- S. Fricke ----------------------------- MAILTO:[email protected]
--
   Diplom-Informatiker (FH)
   Linux-Entwicklung                       JABBER:      [email protected]
----------------------------------------------------------------------------


 
_______________________________________________
Linuxppc-embedded mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-embedded
Signature · 2 lines
View this message in context: http://www.nabble.com/Interrupt-problem-mpc5200-tf4413834.html#a12613692
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
author
#4 lore raw
Quoted 5 lines

Hello,

Is it possible that this call failed?
intr = ioremap(MPC52xx_MBAR+MPC52xx_INTR_OFFSET, MPC52xx_INTR_SIZE);

That call did not fail, but you are right
I have forgotten this snipped

    if(!intr) {
        panic(__FILE__ ": mpc52xx-pic - MAP failed");
    }

Thank you!

Silvio

Mit freundlichen Gruessen
Silvio Fricke

Signature · 4 lines
-- S. Fricke ----------------------------- MAILTO:[email protected] --
   Diplom-Informatiker (FH)
   Linux-Entwicklung                       JABBER:      [email protected]
----------------------------------------------------------------------------