mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
pwm: rockchip: Unify the process of requesting irq for PWM v1-v4
The irq for PWM v1-v3 used to be exclusively associated with oneshot mode, but capture mode also needs interrupt, which does not depend on CONFIG_PWM_ROCKCHIP_ONESHOT. Change-Id: Iaf0e01ec7c5d02d2d379776cba41841d59c46d20 Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
This commit is contained in:
@@ -2259,6 +2259,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
|
||||
const struct of_device_id *id;
|
||||
struct rockchip_pwm_chip *pc;
|
||||
struct resource *r;
|
||||
unsigned long irq_flags;
|
||||
u32 enable_conf, ctrl, version;
|
||||
bool enabled;
|
||||
int ret, count;
|
||||
@@ -2354,37 +2355,25 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
if (pc->data->funcs.irq_handler) {
|
||||
if (pc->main_version >= 4) {
|
||||
pc->irq = platform_get_irq(pdev, 0);
|
||||
if (pc->irq < 0) {
|
||||
dev_err(&pdev->dev, "Get irq failed\n");
|
||||
ret = pc->irq;
|
||||
goto err_pclk;
|
||||
}
|
||||
/*
|
||||
* For pwm v1-v3, the older platform may not support interrupt, and
|
||||
* common continuous mode can still work well without irq.
|
||||
*
|
||||
* For pwm v4, each channel of every controller supports independent
|
||||
* interrupt and the 'interrupts' property is confirmed to be set
|
||||
* for each pwm node.
|
||||
*/
|
||||
pc->irq = platform_get_irq(pdev, 0);
|
||||
if (pc->irq > 0) {
|
||||
irq_flags = pc->main_version >= 4 ? IRQF_NO_SUSPEND :
|
||||
IRQF_NO_SUSPEND | IRQF_SHARED;
|
||||
|
||||
ret = devm_request_irq(&pdev->dev, pc->irq, pc->data->funcs.irq_handler,
|
||||
IRQF_NO_SUSPEND, "rk_pwm_irq", pc);
|
||||
irq_flags, "rk_pwm_irq", pc);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Claim IRQ failed\n");
|
||||
goto err_pclk;
|
||||
}
|
||||
} else {
|
||||
if (IS_ENABLED(CONFIG_PWM_ROCKCHIP_ONESHOT)) {
|
||||
pc->irq = platform_get_irq_optional(pdev, 0);
|
||||
if (pc->irq < 0) {
|
||||
dev_warn(&pdev->dev,
|
||||
"Can't get oneshot mode irq and oneshot interrupt is unsupported\n");
|
||||
} else {
|
||||
ret = devm_request_irq(&pdev->dev, pc->irq,
|
||||
pc->data->funcs.irq_handler,
|
||||
IRQF_NO_SUSPEND | IRQF_SHARED,
|
||||
"rk_pwm_oneshot_irq", pc);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Claim oneshot IRQ failed\n");
|
||||
goto err_pclk;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user