gpio irqs broken on imx27 with dt
Hello,
I experience problems on using gpio irqs on an imx27 based machine booting with dt.
I think one problem is:
if (mxc_gpio_hwtype == IMX21_GPIO) {
/* setup one handler for all GPIO interrupts */
if (pdev->id == 0)
irq_set_chained_handler(port->irq,
mx2_gpio_irq_handler);
} ...because the inner if doesn't trigger as dt-created gpio devices have all pdev->id == -1.
I havn't looked deeper into it yet, but I think another problem is that gpios don't start at 0 and so the usual
#define OTG_PHY_CS_GPIO (GPIO_PORTB + 23)
doesn't work either (which might be expected, but doesn't necessarily needs to fail?!). (You could argue I shouldn't hardcode gpio numbers any more, but as not all device drivers are oftree aware yet I need to get of the ground somehow.)
I'm leaving for the weekend now, so just wanted you to inform that there is a problem. Shawn, maybe you have an idea?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 14 lines · Uwe Kleine-K?nig
Hello,
I experience problems on using gpio irqs on an imx27 based machine booting with dt.
I think one problem is:
if (mxc_gpio_hwtype == IMX21_GPIO) { /* setup one handler for all GPIO interrupts */ if (pdev->id == 0) irq_set_chained_handler(port->irq, mx2_gpio_irq_handler); } ...
Quoted 6 lines
because the inner if doesn't trigger as dt-created gpio devices have all
pdev->id== -1.I havn't looked deeper into it yet, but I think another problem is that gpios don't start at 0 and so the usual
Yes, for dt, gpio base is allocated dynamically.
See gpiochip_find_base.
Quoted 7 lines
#define OTG_PHY_CS_GPIO (GPIO_PORTB + 23)doesn't work either (which might be expected, but doesn't necessarily needs to fail?!). (You could argue I shouldn't hardcode gpio numbers any more, but as not all device drivers are oftree aware yet I need to get of the ground somehow.)
I guess dt user never know a pin's gpio number since they're allocated dynamically. User should only parse it from device tree then it can be safe to use.
Regards
Dong Aisheng
Uwe,
2012/4/27 Uwe Kleine-K?nig <[email protected]>:
Quoted 4 lines
Hello,
I experience problems on using gpio irqs on an imx27 based machine booting with dt.
Currently there is no pinctrl driver for mx27.
What you can do as a temporary workaround is to do the same as mx51 or mx53:
config MACH_IMX51_DT
bool "Support i.MX51 platforms from device tree" select SOC_IMX51
select MACH_MX51_BABBAGE
select USE_OF
help
Include support for Freescale i.MX51 based platforms using the device tree for discovery
MACH_IMX51_DT currently selects MACH_MX51_BABBAGE so that the IOMUX infrastructure can be used.
Regards,
Fabio Estevam
Quoted 14 lines · Uwe Kleine-K?nig
Hello,
I experience problems on using gpio irqs on an imx27 based machine booting with dt.
I think one problem is:
if (mxc_gpio_hwtype == IMX21_GPIO) { /* setup one handler for all GPIO interrupts */ if (pdev->id == 0) irq_set_chained_handler(port->irq, mx2_gpio_irq_handler); } ...
Quoted 2 lines
because the inner if doesn't trigger as dt-created gpio devices have all
pdev->id== -1.
How about
static int once = 0;
if (mxc_gpio_hwtype == IMX21_GPIO) {
/* setup one handler for all GPIO interrupts */
if (!once) {
irq_set_chained_handler(port->irq,
mx2_gpio_irq_handler);
once = 1;
}Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hello,
Quoted 18 lines · Sascha Hauer
Quoted 12 lines · Uwe Kleine-K?nig
I experience problems on using gpio irqs on an imx27 based machine booting with dt.
I think one problem is:
if (mxc_gpio_hwtype == IMX21_GPIO) { /* setup one handler for all GPIO interrupts */ if (pdev->id == 0) irq_set_chained_handler(port->irq, mx2_gpio_irq_handler); } ...Quoted 2 lines
because the inner if doesn't trigger as dt-created gpio devices have all
pdev->id== -1.How about
Quoted 9 lines
static int once = 0;
if (mxc_gpio_hwtype == IMX21_GPIO) {
/* setup one handler for all GPIO interrupts */
if (!once) {
irq_set_chained_handler(port->irq,
mx2_gpio_irq_handler);
once = 1;
}I did exactly this, but it didn't cure all my problems. And it's ugly (not much more than testing pdev->id == 0 though). I'm not sure it's worth to clean that up. (e.g. use a single device for the imx21 type handling all ports vs. one device per port for the latter types. This way each device would handle one and only one irq.)
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |