Hi,
On Mon, Jun 8, 2015 at 3:37 AM, <[email protected]> wrote: > Hello, ALL. > > Could anyone please describe the logic (concept (core) of algorithmic > logic) of how to work with IRQ line for GSL 1680. > Unfortunately on https://linux-sunxi.org/GSL1680 there is nothing about > this. > It will be very gooв to enhance this web page with this information. > > As far as I know it looks that GSL 1680 uses gpio for IRQ. what is the > logic of this? Is it "setting (how?) some gpio to something (to what?) > enables IRQ? > How to hanle farther it and when IRQ happen - could anyone illustrate this > moment with code? > > Regards, > Serge Kolotylo. > The GSL1680 will toggle the gpio pin when it has processed a touch. The kernel driver should setup the gpio pin as an IRQ and attach an IRQ handler to the pin that is called when the gpio pin falls from high to low state. If I remember correctly, the gpio pin is normally in a low state, and the GSL1680 will momentarily pull the gpio high then let it fall. The driver should catch it on the falling edge. In the driver, the irq handler should signal to a worker thread that data is available on the I2C bus. The irq handler should not read the data itself since it takes too long, instead the irq handler should just signal the worker thread and the nexit as fast as it can. You did not say which soc you are using. The way to setup interrupts is different for different soc. I think A10, A13, and A20 do it one way where the gpio has a dedicated external interrupt, while A31 only has a single external interrupt per gpio bank, i.e. A, B, C, etc. and the specific pin which caused the interrupt must be checked through a register. But there are lots of helper framework that takes care of all this for you already. For sample code look in the sunxi-next branch. You can look at /drivers/input/touchscreen/chipone_icn8318.c for example how to setup IRQ and look in /arch/arm/boot/dts/sun5i-a13-utoo-p66.dts for example how to setup device tree for A10, A13, and A20 based chips. icn8318: touchscreen@40 { compatible = "chipone,icn8318"; reg = <0x40>; interrupt-parent = <&pio>; interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* EINT9 (PG9) */ pinctrl-names = "default"; pinctrl-0 = <&ts_wake_pin_p66>; wake-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */ touchscreen-size-x = <800>; touchscreen-size-y = <480>; touchscreen-inverted-x; touchscreen-swapped-x-y; }; For A31, I believe same driver code mostly works, but device tree is different because of banked gpio interrupt. icn8318: touchscreen@40 { compatible = "chipone,icn8318"; reg = <0x40>; interrupt-parent = <&pio>; interrupts = <3 IRQ_TYPE_EDGE_FALLING>; /* (PA3) */ ts-gpios = <&pio 0 3 GPIO_ACTIVE_HIGH>; }; And the way the IRQ is setup needs to change slightly in the probe function. I am doing this as probably incorrect code, so you will need to fix up to make it work in your driver, but you will get general idea. Notice that instead of using irq passed in from I2C client, need to request an irq from gpio because of banked external interrupts. Other kernel code already takes care of checking which pin fired the external interrupt for the bank. For complete example of how the gpio external interrupt works, you can look at the mmc code since mmc uses gpio irq for card detect pin. // Setup the IRQ pin desc = devm_gpiod_get_index(dev, "ts", 0, GPIOD_IN); if (IS_ERR(desc)) return PTR_ERR(desc); irq = gpiod_to_irq(desc); error = devm_request_threaded_irq(dev, irq, NULL, icn8318_irq, IRQF_ONESHOT, client->name, data); -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
