Hello all,
I'm using a imx6ul board (ZLG imx6g2c) to develop a new product.
For some reason, I need a 'good' precision frequency, two differential-signal(s) to drive motor, at about 100Hz.
I have tried soft-delay in application level but it is too crude. That's why I study the PWM/EPIT carefully.
There's a pwm-imx.c in linux kernel tree's ../drivers/pwm/ subdirectory. But the default driver can't provide me
an interrupt service routine to raise dual-differential-signal to drive motor perfectly, I have to write my new driver.
I have written a basic-driver for PWM8 according <<Linux device driver: 3rd edition>>, unfortunately, there
are still some difficult questions:
(1) How can I enable the clock for PWM8 manually?
To avoid driver resource conflicts, I remove all of PWM8 relatived entries in device tree. But the clock source for PWM8 is
disabled automatically. So I have to re-enable it by myself.
I noticed two clock API named 'clk_get_sys()' and 'clk_prepare_enable()', but I have tried:
clk_get_sys("pwm8", NULL);
clk_get_sys("pwm8", "per");
clk_get_sys("pwm8", "ipg");
...
but all of them failed to get a 'struct clk *', so the PWM8 is not really clocked and can't be initted.
(2) How to caculate the IRQ # to call request_irq()?
I noticed the PWM8 interrupt is 149 in <<i.mx6ul reference manual_201508.pdf>>, page 173.
but it seems the Linux kernel throw many & many & many OOPS after these to lines:
......
g_motor.irq = 149;
if (request_irq(g_motor.irq, motor_irq_handler, 0, DEVICE_NAME, &g_motor) != 0)
{
printk(KERN_ALERT DEVICE_NAME ": request_irq(%d) fail.\n", g_motor.irq);
goto request_irq_fail;
}
printk(KERN_INFO "line %d passed, IRQ installed.\n", __LINE__);
......
Of cause, the 'line xxx passed, IRQ installed.' never be printed.
Could anyone help me?