rtc: pcf2127: use IRQ flags obtained from device tree if available
If the interrupt pin of the PCF2127 is routed to the input of a GPIO expander using the pca953x driver, the later will only accept an IRQ of type IRQ_TYPE_EDGE_FALLING or IRQ_TYPE_EDGE_RISING, and the IRQ request will fail. Therefore, allow the IRQ type to be passed from the device tree data if available. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220117225742.1252362-1-hugo@hugovil.com
This commit is contained in:
parent
85bcb01f14
commit
d4785b4634
1 changed files with 12 additions and 1 deletions
|
@ -659,9 +659,20 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||||
clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
|
clear_bit(RTC_FEATURE_ALARM, pcf2127->rtc->features);
|
||||||
|
|
||||||
if (alarm_irq > 0) {
|
if (alarm_irq > 0) {
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If flags = 0, devm_request_threaded_irq() will use IRQ flags
|
||||||
|
* obtained from device tree.
|
||||||
|
*/
|
||||||
|
if (dev_fwnode(dev))
|
||||||
|
flags = 0;
|
||||||
|
else
|
||||||
|
flags = IRQF_TRIGGER_LOW;
|
||||||
|
|
||||||
ret = devm_request_threaded_irq(dev, alarm_irq, NULL,
|
ret = devm_request_threaded_irq(dev, alarm_irq, NULL,
|
||||||
pcf2127_rtc_irq,
|
pcf2127_rtc_irq,
|
||||||
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
flags | IRQF_ONESHOT,
|
||||||
dev_name(dev), dev);
|
dev_name(dev), dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "failed to request alarm irq\n");
|
dev_err(dev, "failed to request alarm irq\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue