Message ID | 20210509233830.359134-1-linus.walleij@linaro.org |
---|---|
State | New |
Headers | show |
Series | Input: tsc200x: Drop hard-coded IRQ edge | expand |
Hi Linus, On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > This edge setting should come from the device tree not > the driver. Also, most device trees sets this to the > falling edge, which is contradictory to what is hardcoded. I see there are 2 possibilities: 1. The driver has never worked 2. DT interrupt annotation is wrong. It would be nice to know if we are dealing with 1 or 2, as in case of #2 we need to adjust DTSes before this patch can be applied. > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > drivers/input/touchscreen/tsc200x-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c > index ce2fe30d6b8a..5f0ce663a2dc 100644 > --- a/drivers/input/touchscreen/tsc200x-core.c > +++ b/drivers/input/touchscreen/tsc200x-core.c > @@ -540,7 +540,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, > > error = devm_request_threaded_irq(dev, irq, NULL, > tsc200x_irq_thread, > - IRQF_TRIGGER_RISING | IRQF_ONESHOT, > + IRQF_ONESHOT, > "tsc200x", ts); > if (error) { > dev_err(dev, "Failed to request irq, err: %d\n", error); > -- > 2.30.2 > Thanks. -- Dmitry
On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > This edge setting should come from the device tree not > > the driver. Also, most device trees sets this to the > > falling edge, which is contradictory to what is hardcoded. > > I see there are 2 possibilities: > > 1. The driver has never worked > 2. DT interrupt annotation is wrong. > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > we need to adjust DTSes before this patch can be applied. I looked closer and unfortunately the mess and confusion is bizarre. The DTS files we know of are: arch/arm/boot/dts/am3517-som.dtsi - rising arch/arm/boot/dts/imx28-tx28.dts - falling arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low arch/arm/boot/dts/imx53-tx53-x03x.dts - falling arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling arch/arm/boot/dts/imx6qdl-tx6.dtsi - none arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none arch/arm/boot/dts/imx7d-nitrogen7.dts - falling arch/arm/boot/dts/logicpd-som-lv.dtsi - rising arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising arch/arm/boot/dts/omap3-gta04.dtsi - falling arch/arm/boot/dts/omap3-n900.dts - rising arch/arm/boot/dts/omap4-var-som-om44.dtsi - low arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling We can assume that some of this is the result of board engineers introducing inverters on the board as is custom, so the flags are actually correct when set to falling, just that we don't model the inverter. In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ type I assume this flag in the driver is actually necessary for the device to work at all. In the cases where rising is set, the addition of the flag is plain tautology, just setting what is already set. In the cases where falling are set the interrupts will arrive on both edges (if the hardware can provide that, which is not always the case) and as a result fire twice as many interrupts as they should, probably with zero effect on the second IRQ, just reporting nothing. The combination with active low is weird. I wonder what happens there. I am just confused now and have no idea what to do about it... But I just CC all the Freescale and OMAP people who seem to maintain these DTS files so they can clarify how well assigned these edges, none and active low (!) IRQs are. Yours, Linus Walleij
Hi, * Linus Walleij <linus.walleij@linaro.org> [210510 09:29]: > On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov > <dmitry.torokhov@gmail.com> wrote: > > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > > > This edge setting should come from the device tree not > > > the driver. Also, most device trees sets this to the > > > falling edge, which is contradictory to what is hardcoded. > > > > I see there are 2 possibilities: > > > > 1. The driver has never worked > > 2. DT interrupt annotation is wrong. > > > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > > we need to adjust DTSes before this patch can be applied. > > I looked closer and unfortunately the mess and confusion > is bizarre. > > The DTS files we know of are: > arch/arm/boot/dts/am3517-som.dtsi - rising > arch/arm/boot/dts/imx28-tx28.dts - falling > arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low > arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low > arch/arm/boot/dts/imx53-tx53-x03x.dts - falling > arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling > arch/arm/boot/dts/imx6qdl-tx6.dtsi - none > arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none > arch/arm/boot/dts/imx7d-nitrogen7.dts - falling > arch/arm/boot/dts/logicpd-som-lv.dtsi - rising > arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising > arch/arm/boot/dts/omap3-gta04.dtsi - falling > arch/arm/boot/dts/omap3-n900.dts - rising > arch/arm/boot/dts/omap4-var-som-om44.dtsi - low > arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling > > We can assume that some of this is the result of board > engineers introducing inverters on the board as is custom, > so the flags are actually correct when set to falling, just > that we don't model the inverter. > > In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ > type I assume this flag in the driver is actually necessary > for the device to work at all. > > In the cases where rising is set, the addition of the flag is > plain tautology, just setting what is already set. > > In the cases where falling are set the interrupts will arrive > on both edges (if the hardware can provide that, which is > not always the case) and as a result fire twice as many > interrupts as they should, probably with zero effect on the > second IRQ, just reporting nothing. > > The combination with active low is weird. I wonder what > happens there. > > I am just confused now and have no idea what to do about > it... > > But I just CC all the Freescale and OMAP people who > seem to maintain these DTS files so they can clarify > how well assigned these edges, none and active low (!) > IRQs are. Maybe the GTA04 or LogicPD folks can check the interrupt edge direction for tsc2005 on the device end to see if inversion happens. So adding some more people to Cc. Looks like at least the tsc2005 data sheet says: "Interrupt output. Data available or PENIRQ depends on setting. Pin polarity with active low." So it seems the dts configuration should have level active low for the GPIO interrupt unless the hardware inverts it somewhere. If the edge configuration for a GPIO interrupt has been done for tsc2005 for PM wake purposes, there should be no longer need for it at least on omaps. Folks can just configure a dedicated wakeirq with interrupts-extended dts property and the i2c framework will handle that automatically :) There are some examples if you grep dts files for '"wakeup"'. Regards, Tony
Hi, > Am 10.05.2021 um 15:41 schrieb Tony Lindgren <tony@atomide.com>: > > Hi, > > * Linus Walleij <linus.walleij@linaro.org> [210510 09:29]: >> On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov >> <dmitry.torokhov@gmail.com> wrote: >>> On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: >> >>>> This edge setting should come from the device tree not >>>> the driver. Also, most device trees sets this to the >>>> falling edge, which is contradictory to what is hardcoded. >>> >>> I see there are 2 possibilities: >>> >>> 1. The driver has never worked >>> 2. DT interrupt annotation is wrong. >>> >>> It would be nice to know if we are dealing with 1 or 2, as in case of #2 >>> we need to adjust DTSes before this patch can be applied. >> >> I looked closer and unfortunately the mess and confusion >> is bizarre. >> >> The DTS files we know of are: >> arch/arm/boot/dts/am3517-som.dtsi - rising >> arch/arm/boot/dts/imx28-tx28.dts - falling >> arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low >> arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low >> arch/arm/boot/dts/imx53-tx53-x03x.dts - falling >> arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling >> arch/arm/boot/dts/imx6qdl-tx6.dtsi - none >> arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none >> arch/arm/boot/dts/imx7d-nitrogen7.dts - falling >> arch/arm/boot/dts/logicpd-som-lv.dtsi - rising >> arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising >> arch/arm/boot/dts/omap3-gta04.dtsi - falling >> arch/arm/boot/dts/omap3-n900.dts - rising >> arch/arm/boot/dts/omap4-var-som-om44.dtsi - low >> arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling >> >> We can assume that some of this is the result of board >> engineers introducing inverters on the board as is custom, >> so the flags are actually correct when set to falling, just >> that we don't model the inverter. >> >> In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ >> type I assume this flag in the driver is actually necessary >> for the device to work at all. >> >> In the cases where rising is set, the addition of the flag is >> plain tautology, just setting what is already set. >> >> In the cases where falling are set the interrupts will arrive >> on both edges (if the hardware can provide that, which is >> not always the case) and as a result fire twice as many >> interrupts as they should, probably with zero effect on the >> second IRQ, just reporting nothing. >> >> The combination with active low is weird. I wonder what >> happens there. >> >> I am just confused now and have no idea what to do about >> it... >> >> But I just CC all the Freescale and OMAP people who >> seem to maintain these DTS files so they can clarify >> how well assigned these edges, none and active low (!) >> IRQs are. > > Maybe the GTA04 or LogicPD folks can check the interrupt edge gt04 uses the tsc2007 which has a driver separate from tsc2004/5. > direction for tsc2005 on the device end to see if inversion > happens. So adding some more people to Cc. > > Looks like at least the tsc2005 data sheet says: > > "Interrupt output. Data available or PENIRQ depends on setting. > Pin polarity with active low." > > So it seems the dts configuration should have level active low > for the GPIO interrupt unless the hardware inverts it somewhere. > > If the edge configuration for a GPIO interrupt has been done > for tsc2005 for PM wake purposes, there should be no longer > need for it at least on omaps. Folks can just configure a > dedicated wakeirq with interrupts-extended dts property and > the i2c framework will handle that automatically :) There are > some examples if you grep dts files for '"wakeup"'. > > Regards, > > Tony BR, Nikolaus
On Mon, May 10, 2021 at 11:29:08AM +0200, Linus Walleij wrote: > On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov > <dmitry.torokhov@gmail.com> wrote: > > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > > > This edge setting should come from the device tree not > > > the driver. Also, most device trees sets this to the > > > falling edge, which is contradictory to what is hardcoded. > > > > I see there are 2 possibilities: > > > > 1. The driver has never worked > > 2. DT interrupt annotation is wrong. > > > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > > we need to adjust DTSes before this patch can be applied. > > I looked closer and unfortunately the mess and confusion > is bizarre. > > The DTS files we know of are: > arch/arm/boot/dts/am3517-som.dtsi - rising > arch/arm/boot/dts/imx28-tx28.dts - falling > arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low > arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low > arch/arm/boot/dts/imx53-tx53-x03x.dts - falling > arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling > arch/arm/boot/dts/imx6qdl-tx6.dtsi - none > arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none > arch/arm/boot/dts/imx7d-nitrogen7.dts - falling > arch/arm/boot/dts/logicpd-som-lv.dtsi - rising > arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising > arch/arm/boot/dts/omap3-gta04.dtsi - falling > arch/arm/boot/dts/omap3-n900.dts - rising > arch/arm/boot/dts/omap4-var-som-om44.dtsi - low > arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling > > We can assume that some of this is the result of board > engineers introducing inverters on the board as is custom, > so the flags are actually correct when set to falling, just > that we don't model the inverter. > > In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ > type I assume this flag in the driver is actually necessary > for the device to work at all. > > In the cases where rising is set, the addition of the flag is > plain tautology, just setting what is already set. > > In the cases where falling are set the interrupts will arrive > on both edges (if the hardware can provide that, which is > not always the case) and as a result fire twice as many > interrupts as they should, probably with zero effect on the > second IRQ, just reporting nothing. That is not how we set up interrupts though. We only use platform-supplied trigger if caller did not specify trigger when calling request_irq(). From kernel/irq/manage.c::__setup_irq(): /* * If the trigger type is not specified by the caller, * then use the default for this interrupt. */ if (!(new->flags & IRQF_TRIGGER_MASK)) new->flags |= irqd_get_trigger_type(&desc->irq_data); So in our case, since driver specified IRQF_TRIGGER_RISING it is how interrupt line was configured, and what was in DTS had no effect. > > The combination with active low is weird. I wonder what > happens there. > > I am just confused now and have no idea what to do about > it... > > But I just CC all the Freescale and OMAP people who > seem to maintain these DTS files so they can clarify > how well assigned these edges, none and active low (!) > IRQs are. Hopefully they can confirm how the controller is wired on their boards and then we can correct invalid DTSes and then finally apply your patch to the driver. Thanks. -- Dmitry
On Mon, May 10, 2021 at 7:39 PM Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > > On Mon, May 10, 2021 at 11:29:08AM +0200, Linus Walleij wrote: > > On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov > > <dmitry.torokhov@gmail.com> wrote: > > > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > > > > > This edge setting should come from the device tree not > > > > the driver. Also, most device trees sets this to the > > > > falling edge, which is contradictory to what is hardcoded. > > > > > > I see there are 2 possibilities: > > > > > > 1. The driver has never worked > > > 2. DT interrupt annotation is wrong. > > > > > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > > > we need to adjust DTSes before this patch can be applied. > > > > I looked closer and unfortunately the mess and confusion > > is bizarre. > > > > The DTS files we know of are: > > arch/arm/boot/dts/am3517-som.dtsi - rising > > arch/arm/boot/dts/imx28-tx28.dts - falling > > arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low > > arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low > > arch/arm/boot/dts/imx53-tx53-x03x.dts - falling > > arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling > > arch/arm/boot/dts/imx6qdl-tx6.dtsi - none > > arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none > > arch/arm/boot/dts/imx7d-nitrogen7.dts - falling > > arch/arm/boot/dts/logicpd-som-lv.dtsi - rising > > arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising > > arch/arm/boot/dts/omap3-gta04.dtsi - falling > > arch/arm/boot/dts/omap3-n900.dts - rising > > arch/arm/boot/dts/omap4-var-som-om44.dtsi - low > > arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling > > > > We can assume that some of this is the result of board > > engineers introducing inverters on the board as is custom, > > so the flags are actually correct when set to falling, just > > that we don't model the inverter. > > > > In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ > > type I assume this flag in the driver is actually necessary > > for the device to work at all. > > > > In the cases where rising is set, the addition of the flag is > > plain tautology, just setting what is already set. > > > > In the cases where falling are set the interrupts will arrive > > on both edges (if the hardware can provide that, which is > > not always the case) and as a result fire twice as many > > interrupts as they should, probably with zero effect on the > > second IRQ, just reporting nothing. > > That is not how we set up interrupts though. We only use > platform-supplied trigger if caller did not specify trigger when calling > request_irq(). From kernel/irq/manage.c::__setup_irq(): > > /* > * If the trigger type is not specified by the caller, > * then use the default for this interrupt. > */ > if (!(new->flags & IRQF_TRIGGER_MASK)) > new->flags |= irqd_get_trigger_type(&desc->irq_data); > > So in our case, since driver specified IRQF_TRIGGER_RISING it is how > interrupt line was configured, and what was in DTS had no effect. > > > > > The combination with active low is weird. I wonder what > > happens there. > > > > I am just confused now and have no idea what to do about > > it... > > > > But I just CC all the Freescale and OMAP people who > > seem to maintain these DTS files so they can clarify > > how well assigned these edges, none and active low (!) > > IRQs are. > > Hopefully they can confirm how the controller is wired on their boards > and then we can correct invalid DTSes and then finally apply your patch > to the driver. I reviewed the Logicpd Torpedo (DM3730) and there isn't an interter. I changed the device tree entry for it to falling edge instead and rising, and it continued to work perfectly. I'll review both the schematics and test the am3517-evm and the logicpd som-lv, but I am going to expect the same results since they'll all basically copy-paste of each other. Once I've completed my analysis, I'll post device tree updates for all the logicpd stuff. adam > > Thanks. > > -- > Dmitry
On Tue, May 11, 2021 at 01:24:00PM -0500, Adam Ford wrote: > On Mon, May 10, 2021 at 7:39 PM Dmitry Torokhov > <dmitry.torokhov@gmail.com> wrote: > > > > On Mon, May 10, 2021 at 11:29:08AM +0200, Linus Walleij wrote: > > > On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov > > > <dmitry.torokhov@gmail.com> wrote: > > > > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > > > > > > > This edge setting should come from the device tree not > > > > > the driver. Also, most device trees sets this to the > > > > > falling edge, which is contradictory to what is hardcoded. > > > > > > > > I see there are 2 possibilities: > > > > > > > > 1. The driver has never worked > > > > 2. DT interrupt annotation is wrong. > > > > > > > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > > > > we need to adjust DTSes before this patch can be applied. > > > > > > I looked closer and unfortunately the mess and confusion > > > is bizarre. > > > > > > The DTS files we know of are: > > > arch/arm/boot/dts/am3517-som.dtsi - rising > > > arch/arm/boot/dts/imx28-tx28.dts - falling > > > arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low > > > arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low > > > arch/arm/boot/dts/imx53-tx53-x03x.dts - falling > > > arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling > > > arch/arm/boot/dts/imx6qdl-tx6.dtsi - none > > > arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none > > > arch/arm/boot/dts/imx7d-nitrogen7.dts - falling > > > arch/arm/boot/dts/logicpd-som-lv.dtsi - rising > > > arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising > > > arch/arm/boot/dts/omap3-gta04.dtsi - falling > > > arch/arm/boot/dts/omap3-n900.dts - rising > > > arch/arm/boot/dts/omap4-var-som-om44.dtsi - low > > > arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling > > > > > > We can assume that some of this is the result of board > > > engineers introducing inverters on the board as is custom, > > > so the flags are actually correct when set to falling, just > > > that we don't model the inverter. > > > > > > In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ > > > type I assume this flag in the driver is actually necessary > > > for the device to work at all. > > > > > > In the cases where rising is set, the addition of the flag is > > > plain tautology, just setting what is already set. > > > > > > In the cases where falling are set the interrupts will arrive > > > on both edges (if the hardware can provide that, which is > > > not always the case) and as a result fire twice as many > > > interrupts as they should, probably with zero effect on the > > > second IRQ, just reporting nothing. > > > > That is not how we set up interrupts though. We only use > > platform-supplied trigger if caller did not specify trigger when calling > > request_irq(). From kernel/irq/manage.c::__setup_irq(): > > > > /* > > * If the trigger type is not specified by the caller, > > * then use the default for this interrupt. > > */ > > if (!(new->flags & IRQF_TRIGGER_MASK)) > > new->flags |= irqd_get_trigger_type(&desc->irq_data); > > > > So in our case, since driver specified IRQF_TRIGGER_RISING it is how > > interrupt line was configured, and what was in DTS had no effect. > > > > > > > > The combination with active low is weird. I wonder what > > > happens there. > > > > > > I am just confused now and have no idea what to do about > > > it... > > > > > > But I just CC all the Freescale and OMAP people who > > > seem to maintain these DTS files so they can clarify > > > how well assigned these edges, none and active low (!) > > > IRQs are. > > > > Hopefully they can confirm how the controller is wired on their boards > > and then we can correct invalid DTSes and then finally apply your patch > > to the driver. > > I reviewed the Logicpd Torpedo (DM3730) and there isn't an interter. > I changed the device tree entry for it to falling edge instead and > rising, and it continued to work perfectly. > > I'll review both the schematics and test the am3517-evm and the > logicpd som-lv, but I am going to expect the same results since > they'll all basically copy-paste of each other. > > Once I've completed my analysis, I'll post device tree updates for all > the logicpd stuff. OK, so this is quite complicated. According to the datasheets [1], [2] the ^PINTDAV pin is an active low pin, but in the default mode of touchcsreen the "value" of the pin is logical AND of ^PENIRQ (active low) and DAV [data available] (active high), which essentially turns it into "edge" interrupt with data being available when pin is transitioning from low to high. See fig 39 in [1] and 32 in [2]. This explains all the confusion in DTSes. The driver is using this default mode, but this is not purely hardware configuration. I think what we need is to have DTS to specify level, either low or high, to allow handle presence of an inverter, and have driver check the assigned polarity and convert it to the right edge as long as it continues using the default method of handling of PINTDAV. WDYT? [1] https://www.ti.com/lit/ds/symlink/tsc2004.pdf [2] https://www.ti.com/lit/ds/symlink/tsc2005.pdf Thanks. -- Dmitry
On Tue, May 11, 2021 at 4:09 PM Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > > On Tue, May 11, 2021 at 01:24:00PM -0500, Adam Ford wrote: > > On Mon, May 10, 2021 at 7:39 PM Dmitry Torokhov > > <dmitry.torokhov@gmail.com> wrote: > > > > > > On Mon, May 10, 2021 at 11:29:08AM +0200, Linus Walleij wrote: > > > > On Mon, May 10, 2021 at 2:22 AM Dmitry Torokhov > > > > <dmitry.torokhov@gmail.com> wrote: > > > > > On Mon, May 10, 2021 at 01:38:30AM +0200, Linus Walleij wrote: > > > > > > > > > > This edge setting should come from the device tree not > > > > > > the driver. Also, most device trees sets this to the > > > > > > falling edge, which is contradictory to what is hardcoded. > > > > > > > > > > I see there are 2 possibilities: > > > > > > > > > > 1. The driver has never worked > > > > > 2. DT interrupt annotation is wrong. > > > > > > > > > > It would be nice to know if we are dealing with 1 or 2, as in case of #2 > > > > > we need to adjust DTSes before this patch can be applied. > > > > > > > > I looked closer and unfortunately the mess and confusion > > > > is bizarre. > > > > > > > > The DTS files we know of are: > > > > arch/arm/boot/dts/am3517-som.dtsi - rising > > > > arch/arm/boot/dts/imx28-tx28.dts - falling > > > > arch/arm/boot/dts/imx35-eukrea-cpuimx35.dtsi - low > > > > arch/arm/boot/dts/imx51-eukrea-cpuimx51.dtsi - low > > > > arch/arm/boot/dts/imx53-tx53-x03x.dts - falling > > > > arch/arm/boot/dts/imx6q-dhcom-som.dtsi - falling > > > > arch/arm/boot/dts/imx6qdl-tx6.dtsi - none > > > > arch/arm/boot/dts/imx6ul-tx6ul.dtsi - none > > > > arch/arm/boot/dts/imx7d-nitrogen7.dts - falling > > > > arch/arm/boot/dts/logicpd-som-lv.dtsi - rising > > > > arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi - rising > > > > arch/arm/boot/dts/omap3-gta04.dtsi - falling > > > > arch/arm/boot/dts/omap3-n900.dts - rising > > > > arch/arm/boot/dts/omap4-var-som-om44.dtsi - low > > > > arch/arm/boot/dts/stm32mp15xx-dhcom-som.dtsi - falling > > > > > > > > We can assume that some of this is the result of board > > > > engineers introducing inverters on the board as is custom, > > > > so the flags are actually correct when set to falling, just > > > > that we don't model the inverter. > > > > > > > > In the case of imx6qdl-tx6 and imx6ul-tx6ul with "none" IRQ > > > > type I assume this flag in the driver is actually necessary > > > > for the device to work at all. > > > > > > > > In the cases where rising is set, the addition of the flag is > > > > plain tautology, just setting what is already set. > > > > > > > > In the cases where falling are set the interrupts will arrive > > > > on both edges (if the hardware can provide that, which is > > > > not always the case) and as a result fire twice as many > > > > interrupts as they should, probably with zero effect on the > > > > second IRQ, just reporting nothing. > > > > > > That is not how we set up interrupts though. We only use > > > platform-supplied trigger if caller did not specify trigger when calling > > > request_irq(). From kernel/irq/manage.c::__setup_irq(): > > > > > > /* > > > * If the trigger type is not specified by the caller, > > > * then use the default for this interrupt. > > > */ > > > if (!(new->flags & IRQF_TRIGGER_MASK)) > > > new->flags |= irqd_get_trigger_type(&desc->irq_data); > > > > > > So in our case, since driver specified IRQF_TRIGGER_RISING it is how > > > interrupt line was configured, and what was in DTS had no effect. > > > > > > > > > > > The combination with active low is weird. I wonder what > > > > happens there. > > > > > > > > I am just confused now and have no idea what to do about > > > > it... > > > > > > > > But I just CC all the Freescale and OMAP people who > > > > seem to maintain these DTS files so they can clarify > > > > how well assigned these edges, none and active low (!) > > > > IRQs are. > > > > > > Hopefully they can confirm how the controller is wired on their boards > > > and then we can correct invalid DTSes and then finally apply your patch > > > to the driver. > > > > I reviewed the Logicpd Torpedo (DM3730) and there isn't an interter. > > I changed the device tree entry for it to falling edge instead and > > rising, and it continued to work perfectly. > > > > I'll review both the schematics and test the am3517-evm and the > > logicpd som-lv, but I am going to expect the same results since > > they'll all basically copy-paste of each other. > > > > Once I've completed my analysis, I'll post device tree updates for all > > the logicpd stuff. > > OK, so this is quite complicated. According to the datasheets [1], [2] > the ^PINTDAV pin is an active low pin, but in the default mode of > touchcsreen the "value" of the pin is logical AND of ^PENIRQ (active > low) and DAV [data available] (active high), which essentially turns it > into "edge" interrupt with data being available when pin is > transitioning from low to high. See fig 39 in [1] and 32 in [2]. > This explains all the confusion in DTSes. The bindings in tsc2005.txt also state rising, but if you simply look at the schematic symbol which shows active low, it's really easy for me to see why there would be confusion. > > The driver is using this default mode, but this is not purely hardware > configuration. I think what we need is to have DTS to specify level, > either low or high, to allow handle presence of an inverter, and have > driver check the assigned polarity and convert it to the right edge as > long as it continues using the default method of handling of PINTDAV. > > WDYT? Personally, I have never been a fan of hard-coding IRQ's or GPIO's, because some hardware implementations may use inverters for various reasons, so I am always in favor of actually using the device tree to specify it. Since the driver is currently hard-coded, it seems reasonable to me to unify all the device trees with whatever the current hard-coded value is first. I think doing so would better reflect what's happening now. If we leave the device trees unchanged, any code chance to handle the IRQ differently may appear to break functionality when in fact, it would potentially be an incorrect device tree. I am happy to test code changes on the TSC2004's implementations that I have if you need. adam > > [1] https://www.ti.com/lit/ds/symlink/tsc2004.pdf > [2] https://www.ti.com/lit/ds/symlink/tsc2005.pdf > > Thanks. > > -- > Dmitry
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c index ce2fe30d6b8a..5f0ce663a2dc 100644 --- a/drivers/input/touchscreen/tsc200x-core.c +++ b/drivers/input/touchscreen/tsc200x-core.c @@ -540,7 +540,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, error = devm_request_threaded_irq(dev, irq, NULL, tsc200x_irq_thread, - IRQF_TRIGGER_RISING | IRQF_ONESHOT, + IRQF_ONESHOT, "tsc200x", ts); if (error) { dev_err(dev, "Failed to request irq, err: %d\n", error);
This edge setting should come from the device tree not the driver. Also, most device trees sets this to the falling edge, which is contradictory to what is hardcoded. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/input/touchscreen/tsc200x-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.2