Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => RK3188 => Topic started by: sfaragnaus on March 07, 2017, 04:27:14 AM

Title: PWM interrupt error on RK3188
Post by: sfaragnaus on March 07, 2017, 04:27:14 AM
I'm using Linux 3.0.36 on an Olimex RK3188 SOM, trying to leverage PWM interrupt functionality (on channel 3 for example). The module setup code is something like the following:

Code: [Select]
#define PWM_ID  3
#define PWM_IRQ IRQ_PWM3
#define PWM_NO  PWM3

clk = clk_get(NULL, "pwm23");
if (IS_ERR(clk)) {
    ret = PTR_ERR(clk);
    printk("Can't get pwm clk: %d\n", ret);
    goto cleanup;
ret = clk_enable(clk);
if (ret) {
    printk("Can't prepare pwm clk: %d\n", ret);
    goto cleanup;
spin_lock_irqsave(&lock, flags);

const void __iomem *base = rk_pwm_get_base(PWM_ID);
u32 reset = PWM_DIV2 | PWM_RESET;
u32 off = PWM_DIV2;
u32 int_ena = (1<<5);
writel_relaxed(reset, base + PWM_REG_CTRL);
writel_relaxed(111/2, base + PWM_REG_HRC);
writel_relaxed(111, base + PWM_REG_LRC);
writel_relaxed(0, base + PWM_REG_CNTR);
writel_relaxed(off | int_ena, base + PWM_REG_CTRL);
writel_relaxed(on | int_ena, base + PWM_REG_CTRL);
spin_unlock_irqrestore(&lock, flags);

if ((ret = request_irq(PWM_IRQ, pwm_irq_handler, IRQ_TYPE_EDGE_RISING, "pwm", NULL)))
    printk(KERN_ERR"INT RET: %d\n", ret);

I can see the PWM on pin on the relevant pin but the interrupt handler is never called. I expect to have it called on counter register rollover. Peeking on the GFR register says that interrupt is enabled, still I have no activity. Also:

Code: [Select]
cat /proc/interrupts |grep pwm
shows a line for the interrupt but all trigger number are 0. Also, the PWM_CTRL interrupt status register and the corresponding status register in the GIC are off, as if the interrupt has never been signalled. Anyone does know if there could a misconfiguration on my part or maybe a silicon bug?

Many thanks