[PATCH v2] irqchip/irq-mst: Support polarity configuration

Mark-PK Tsai mark-pk.tsai at mediatek.com
Thu Mar 11 03:12:42 GMT 2021


From: Daniel Palmer <daniel at 0x0f.com>

>On Mon, 8 Mar 2021 at 23:30, Mark-PK Tsai <mark-pk.tsai at mediatek.com> wrote:
>> From: Daniel Palmer <daniel at 0x0f.com>
>> >On Mon, 8 Mar 2021 at 15:05, Mark-PK Tsai <mark-pk.tsai at mediatek.com> wrote:
>> >> +static int mst_irq_chip_set_type(struct irq_data *data, unsigned int type)
>> >       > +{
>> >> +       if (type != IRQ_TYPE_LEVEL_LOW && type != IRQ_TYPE_LEVEL_HIGH)
>> >> +               return -EINVAL;
>> >> +
>> >
>> >Does this mean we can't do rising or falling edge interrupts?
>>
>> Yes, the interrupt of mst-intc is either level high or level low.
>> Actually the input signal can be pulse, but it will be converted to level
>> by the latch in mst-intc.
>
>Are the GPIO connected interrupts meant to be configured as level
>interrupts then?
>For the MStar MSC313(e) there are 4 (that I know of) GPIO lines that
>are wired into the mst-intc that requires EOI.
>Until this patch with those lines configured as a rising edge a single
>interrupt came each time the GPIO was pulled up as far as I remember.
>
>I'm probably misunderstanding but a level interrupt doesn't seem to
>make sense for a GPIO as it can't be serviced to clear the interrupt.


As I understand it, there are 2 types of mst-intc, one we need do EOI
operation(fiq) and the other we don't(irq).
For a fiq controller, the input edge signal will be convert to level and
keep the interrupt status until we do EOI operation.
That means if a rising edge input if trigger the ouput line will keep high
until we clear the interrupt status.

And I think you're right, make these kind of interrupts edge may make more sense.
So I will modify the patch as following:

 static int mst_irq_chip_set_type(struct irq_data *data, unsigned int type)
 {
-       if (type != IRQ_TYPE_LEVEL_LOW && type != IRQ_TYPE_LEVEL_HIGH)
-               return -EINVAL;
-
-       if (type == IRQ_TYPE_LEVEL_LOW) {
+       if (type == IRQ_TYPE_EDGE_FALLING) {
+               mst_set_irq(data, INTC_REV_POLARITY);
+               type = IRQ_TYPE_EDGE_RISING;
+       } else if (type == IRQ_TYPE_LEVEL_LOW) {
                mst_set_irq(data, INTC_REV_POLARITY);
                type = IRQ_TYPE_LEVEL_HIGH;
        }


More information about the linux-arm-kernel mailing list