Message ID | 20201210212534.216197-18-krzk@kernel.org |
---|---|
State | New |
Headers | show |
Series | None | expand |
On Thu, Dec 10, 2020 at 10:25:34PM +0100, Krzysztof Kozlowski wrote: > Interrupt line can be configured on different hardware in different way, > even inverted. Therefore driver should not enforce specific trigger > type - edge falling - but instead rely on Devicetree to configure it. > > The Maxim 14577/77836 datasheets describe the interrupt line as active > low with a requirement of acknowledge from the CPU therefore the edge > falling is not correct. > > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> > > --- > > This patch should wait till DTS changes are merged, as it relies on > proper Devicetree. > --- > .../devicetree/bindings/power/supply/max17040_battery.txt | 2 +- > drivers/power/supply/max17040_battery.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > index c802f664b508..194eb9fe574d 100644 > --- a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > +++ b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > @@ -39,7 +39,7 @@ Example: > reg = <0x36>; > maxim,alert-low-soc-level = <10>; > interrupt-parent = <&gpio7>; > - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; > + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; > wakeup-source; > }; > > diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c > index d956c67d5155..f737de0470de 100644 > --- a/drivers/power/supply/max17040_battery.c > +++ b/drivers/power/supply/max17040_battery.c > @@ -367,7 +367,7 @@ static int max17040_enable_alert_irq(struct max17040_chip *chip) > > flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; This has to be removed. I will fix it in v2. Best regards, Krzysztof > ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, > - max17040_thread_handler, flags, > + max17040_thread_handler, IRQF_ONESHOT, > chip->battery->desc->name, chip); > > return ret; > -- > 2.25.1 >
On 12/11/20 9:47 AM, Krzysztof Kozlowski wrote: > On Thu, Dec 10, 2020 at 10:25:34PM +0100, Krzysztof Kozlowski wrote: >> Interrupt line can be configured on different hardware in different way, >> even inverted. Therefore driver should not enforce specific trigger >> type - edge falling - but instead rely on Devicetree to configure it. >> >> The Maxim 14577/77836 datasheets describe the interrupt line as active >> low with a requirement of acknowledge from the CPU therefore the edge >> falling is not correct. >> >> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> >> >> --- >> >> This patch should wait till DTS changes are merged, as it relies on >> proper Devicetree. >> --- >> .../devicetree/bindings/power/supply/max17040_battery.txt | 2 +- >> drivers/power/supply/max17040_battery.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt >> index c802f664b508..194eb9fe574d 100644 >> --- a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt >> +++ b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt >> @@ -39,7 +39,7 @@ Example: >> reg = <0x36>; >> maxim,alert-low-soc-level = <10>; >> interrupt-parent = <&gpio7>; >> - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; >> + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; >> wakeup-source; >> }; >> >> diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c >> index d956c67d5155..f737de0470de 100644 >> --- a/drivers/power/supply/max17040_battery.c >> +++ b/drivers/power/supply/max17040_battery.c >> @@ -367,7 +367,7 @@ static int max17040_enable_alert_irq(struct max17040_chip *chip) >> >> flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; > > This has to be removed. I will fix it in v2. > > Best regards, > Krzysztof I removed the IRQF_TRIGGER_FALLING, tweaked the DT as per the DT patch, and it worked on the samsung klte. I don't understand how the DT irq flag ends up being used by the kernel. It is never explicitly read from DT or passed to interrupt API, only i2c->irq, which is a pure int. Fixing the DT and the drivers will hopefully set a precedent, so future drivers (when copied/tweaked from existing drivers) will do it right. Acked-by: Iskren Chernev <iskren.chernev@gmail.com> >> ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, >> - max17040_thread_handler, flags, >> + max17040_thread_handler, IRQF_ONESHOT, >> chip->battery->desc->name, chip); >> >> return ret; >> -- >> 2.25.1 >>
On Fri, Dec 11, 2020 at 05:44:26PM +0200, Iskren Chernev wrote: > > On 12/11/20 9:47 AM, Krzysztof Kozlowski wrote: > > On Thu, Dec 10, 2020 at 10:25:34PM +0100, Krzysztof Kozlowski wrote: > >> Interrupt line can be configured on different hardware in different way, > >> even inverted. Therefore driver should not enforce specific trigger > >> type - edge falling - but instead rely on Devicetree to configure it. > >> > >> The Maxim 14577/77836 datasheets describe the interrupt line as active > >> low with a requirement of acknowledge from the CPU therefore the edge > >> falling is not correct. > >> > >> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> > >> > >> --- > >> > >> This patch should wait till DTS changes are merged, as it relies on > >> proper Devicetree. > >> --- > >> .../devicetree/bindings/power/supply/max17040_battery.txt | 2 +- > >> drivers/power/supply/max17040_battery.c | 2 +- > >> 2 files changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git > a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > >> index c802f664b508..194eb9fe574d 100644 > >> --- a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > >> +++ b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt > >> @@ -39,7 +39,7 @@ Example: > >> reg = <0x36>; > >> maxim,alert-low-soc-level = <10>; > >> interrupt-parent = <&gpio7>; > >> - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; > >> + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; > >> wakeup-source; > >> }; > >> > >> diff --git a/drivers/power/supply/max17040_battery.c > b/drivers/power/supply/max17040_battery.c > >> index d956c67d5155..f737de0470de 100644 > >> --- a/drivers/power/supply/max17040_battery.c > >> +++ b/drivers/power/supply/max17040_battery.c > >> @@ -367,7 +367,7 @@ static int max17040_enable_alert_irq(struct > max17040_chip *chip) > >> > >> flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; > > > > This has to be removed. I will fix it in v2. > > > > Best regards, > > Krzysztof > > I removed the IRQF_TRIGGER_FALLING, tweaked the DT as per the DT patch, and > it worked on the samsung klte. > > I don't understand how the DT irq flag ends up being used by the kernel. It > is never explicitly read from DT or passed to interrupt API, only i2c->irq, > which is a pure int. The core __setup_irq() calls irqd_get_trigger_type() on IRQ data matching the IRQ. Best regards, Krzysztof
diff --git a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt index c802f664b508..194eb9fe574d 100644 --- a/Documentation/devicetree/bindings/power/supply/max17040_battery.txt +++ b/Documentation/devicetree/bindings/power/supply/max17040_battery.txt @@ -39,7 +39,7 @@ Example: reg = <0x36>; maxim,alert-low-soc-level = <10>; interrupt-parent = <&gpio7>; - interrupts = <2 IRQ_TYPE_EDGE_FALLING>; + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; wakeup-source; }; diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index d956c67d5155..f737de0470de 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -367,7 +367,7 @@ static int max17040_enable_alert_irq(struct max17040_chip *chip) flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, - max17040_thread_handler, flags, + max17040_thread_handler, IRQF_ONESHOT, chip->battery->desc->name, chip); return ret;
Interrupt line can be configured on different hardware in different way, even inverted. Therefore driver should not enforce specific trigger type - edge falling - but instead rely on Devicetree to configure it. The Maxim 14577/77836 datasheets describe the interrupt line as active low with a requirement of acknowledge from the CPU therefore the edge falling is not correct. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> --- This patch should wait till DTS changes are merged, as it relies on proper Devicetree. --- .../devicetree/bindings/power/supply/max17040_battery.txt | 2 +- drivers/power/supply/max17040_battery.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)