Skip to contentSkip to conversation

Requestirq() = freeze for touchscreendriver

DISCUSSION Kristoffer Ericson 3 participants 7 messages Feb 7, 2008 – Feb 9, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Greetings,

Been bugtracking touchscreen driver, seems like it gets stuck on IRQ request. irq = 35 in this case. Im still bad at recalculating but vect 0x660 = 35?

I've rewritten the driver to platform driver (old driver been broken for approx 2-3months now anyways), so I've added it to hp6xx_devices_setup to make it start with rest of devices (keyboard / leds / ....)

from my arch/sh/boards/hp6xx/setup.c:

static struct platform_device jornadats_device = {
	.name		= "jornada_ts",
	.id		= -1,
};
static struct platform_device *hp6xx_devices[] __initdata = {
	&cf_ide_device,
	&jornadakbd_device,
	&jornadats_device,
	&hp6xxled_device,
};

static void __init hp6xx_init_irq(void)

{
	/* Gets touchscreen and powerbutton IRQ working */
	plat_irq_setup_pins(IRQ_MODE_IRQ);
}

static int __init hp6xx_devices_setup(void)

{
	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
}

I got two other likely candidates :
1) the new base io_map I added (strange that nothing else fails though)
2) plat_irq_setup MUST be finished before hp6xx_devices_setup starts, otherwise I suspect the IRQ3 would never reach IRQ_MODE.

static void __iomem *port_map(unsigned long port, unsigned int size)

{
    /* this is for all drivers actually accepting io_offset */
    if (0xf300<=port && port<=0xf31f)
	port = port - 0xf000;

    /* non-port? then just return it */
    if (PXSEG(port))
	return (void __iomem *)(port);

    /* add base value and return it */
    return (void __iomem *)(0xba000000 + port);
}

Ideas?

#1 lore raw
Quoted 3 lines · Kristoffer Ericson

Been bugtracking touchscreen driver, seems like it gets stuck on IRQ request. irq = 35 in this case. Im still bad at recalculating but vect 0x660 = 35?

The math for calculating this can be found in the headers. Write a test app to convert for you if you aren't sure.

Quoted 7 lines

static void __init hp6xx_init_irq(void)

{
	/* Gets touchscreen and powerbutton IRQ working */
	plat_irq_setup_pins(IRQ_MODE_IRQ);
}

static int __init hp6xx_devices_setup(void)

Quoted 9 lines
{
	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
}

I got two other likely candidates :
1) the new base io_map I added (strange that nothing else fails though)
2) plat_irq_setup MUST be finished before hp6xx_devices_setup starts, otherwise I suspect the IRQ3 would never reach IRQ_MODE.

Unfortunately you've not posted enough context to figure out the initialization sequence. Please post your patch (and as a patch, not an inlined file) if you want feedback.

#2 lore raw
In reply to Kristoffer Ericson

Greetings,

These patches are against vanilla 2.6.24, but should apply cleanly to linux-2.6 also. hp6xx_ts_input.patch creates platform_driver for the touchscreen, not much is kept from the old.

The booting comes to "waiting to aquire IRQ" and then freezes. So it happens in one of these lines :

	printk(KERN_INFO "ts: waiting to request IRQ\n");
	error = request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
			IRQF_DISABLED, "HP6XX Touchscreen Driver", pdev);
		
	if (error) {
	    printk(KERN_INFO "hp680_touchscreen.c: Unable to aquire irq %d\n", HP680_TS_IRQ);
	    goto fail2;
	}
	error = input_register_device(jornada_ts->dev);
	if (error)
	    goto fail1;
	printk(KERN_INFO "ts: passed probing successfully\n");
	return 0;
arch/sh/boards/hp6xx/setup.c +47 -17
index 2f414ac..7b5b273 100644
@@ -12,7 +12,7 @@
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <asm/hd64461.h>
+#include <asm/hd6446x.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/hp6xx.h>
@@ -21,7 +21,7 @@
 #define	SCPCR	0xa4000116
 #define	SCPDR	0xa4000136
 
-/* CF Slot */
+/* CF slot configured as storage */
 static struct resource cf_ide_resources[] = {
 	[0] = {
 		.start = 0x15000000 + 0x1f0,
@@ -51,9 +51,21 @@ static struct platform_device jornadakbd_device = {
 	.id		= -1,
 };
 
+static struct platform_device hp6xxled_device = {
+	.name		= "hp6xx-led",
+	.id		= -1,
+};
+
+static struct platform_device jornadats_device = {
+	.name		= "jornada_ts",
+	.id		= -1,
+};
+
 static struct platform_device *hp6xx_devices[] __initdata = {
 	&cf_ide_device,
 	&jornadakbd_device,
+	&jornadats_device,
+	&hp6xxled_device,
 };
 
 static void __init hp6xx_init_irq(void)
@@ -72,24 +84,26 @@ static void __init hp6xx_setup(char **cmdline_p)
 	u8 v8;
 	u16 v;
 
-	v = inw(HD64461_STBCR);
-	v |=	HD64461_STBCR_SURTST | HD64461_STBCR_SIRST	|
-		HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST	|
-		HD64461_STBCR_SAFEST | HD64461_STBCR_SPC0ST	|
-		HD64461_STBCR_SMIAST | HD64461_STBCR_SAFECKE_OST|
-		HD64461_STBCR_SAFECKE_IST;
+	v = inw(HD6446x_STBCR);
+	v |=	HD6446x_STBCR_URT    | HD6446x_STBCR_IRDA	|
+		HD6446x_STBCR_TMU1   | HD6446x_STBCR_TMU0	|
+		HD6446x_STBCR_AFE    | HD6446x_STBCR_PCC0	|
+		HD6446x_STBCR_PP     | HD6446x_STBCR_SAFECKE_OST|
+		HD6446x_STBCR_ADC;
 #ifndef CONFIG_HD64461_ENABLER
-	v |= HD64461_STBCR_SPC1ST;
+	v |= HD6446x_STBCR_PCC1;
 #endif
-	outw(v, HD64461_STBCR);
-	v = inw(HD64461_GPADR);
+	outw(v, HD6446x_STBCR);
+	v = inw(HD6446x_GPADR);
 	v |= HD64461_GPADR_SPEAKER | HD64461_GPADR_PCMCIA0;
-	outw(v, HD64461_GPADR);
+	outw(v, HD6446x_GPADR);
 
-	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC0GCR);
+	/* set voltage control pin to high level (PCC0SEL)*/
+	outw(HD6446x_PCCGCR_VCC0 | HD6446x_PCCSCR_VCC1, HD6446x_PCC0GCR);
 
 #ifndef CONFIG_HD64461_ENABLER
-	outw(HD64461_PCCGCR_VCC0 | HD64461_PCCSCR_VCC1, HD64461_PCC1GCR);
+	/* set voltage control pin to high level (PCC1SEL)*/
+	outw(HD6446x_PCCGCR_VCC0 | HD6446x_PCCSCR_VCC1, HD6446x_PCC1GCR);
 #endif
 
 	sh_dac_output(0, DAC_SPEAKER_VOLUME);
@@ -107,15 +121,31 @@ static void __init hp6xx_setup(char **cmdline_p)
 	v &= ~SCPCR_TS_MASK;
 	v |= SCPCR_TS_ENABLE;
 	ctrl_outw(v, SCPCR);
+
 }
 device_initcall(hp6xx_devices_setup);
 
+static void __iomem *port_map(unsigned long port, unsigned int size)
+{
+    /* this is for all drivers actually accepting io_offset */
+    if (0xf300<=port && port<=0xf31f)
+	port = port - 0xf000;
+
+    /* non-port? then just return it */
+    if (PXSEG(port))
+	return (void __iomem *)(port);
+
+    /* add base value and return it */
+    return (void __iomem *)(0xba000000 + port);
+}
+
 static struct sh_machine_vector mv_hp6xx __initmv = {
-	.mv_name = "hp6xx",
+	.mv_name = "HP Jornada 6xx",
 	.mv_setup = hp6xx_setup,
 	/* IRQ's : CPU(64) + CCHIP(16) + FREE_TO_USE(6) */
-	.mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM + 6,
-	.mv_irq_demux = hd64461_irq_demux,
+	.mv_nr_irqs = HD6446x_IRQBASE + HD6446x_IRQ_NUM + 6,
+	.mv_irq_demux = hd6446x_irq_demux,
 	/* Enable IRQ0 -> IRQ3 in IRQ_MODE */
 	.mv_init_irq = hp6xx_init_irq,
+	.mv_ioport_map = port_map,
 };
drivers/input/touchscreen/hp680_ts_input.c +109 -65

229 lines not on this page · raw message

Quoted 18 lines · On Thu, 7 Feb 2008 11:38:14 +0900 Paul Mundt <[email protected]> wrote:
Quoted 3 lines · Kristoffer Ericson

Been bugtracking touchscreen driver, seems like it gets stuck on IRQ request. irq = 35 in this case. Im still bad at recalculating but vect 0x660 = 35?

The math for calculating this can be found in the headers. Write a test app to convert for you if you aren't sure.

Quoted 11 lines

static void __init hp6xx_init_irq(void)

{
	/* Gets touchscreen and powerbutton IRQ working */
	plat_irq_setup_pins(IRQ_MODE_IRQ);
}

static int __init hp6xx_devices_setup(void)

{
	return platform_add_devices(hp6xx_devices, ARRAY_SIZE(hp6xx_devices));
}
Quoted 8 lines
Quoted 5 lines

I got two other likely candidates :
1) the new base io_map I added (strange that nothing else fails though)
2) plat_irq_setup MUST be finished before hp6xx_devices_setup starts, otherwise I suspect the IRQ3 would never reach IRQ_MODE.

Unfortunately you've not posted enough context to figure out the initialization sequence. Please post your patch (and as a patch, not an inlined file) if you want feedback.

arch/sh/boards/hp6xx/setup.c +47 -17

109 lines not on this page · raw message

drivers/input/touchscreen/hp680_ts_input.c +109 -65

229 lines not on this page · raw message

#3 lore raw
In reply to Kristoffer Ericson

Hi Kristoffer,

Quoted 9 lines · Kristoffer Ericson

Greetings,

These patches are against vanilla 2.6.24, but should apply cleanly to linux-2.6 also. hp6xx_ts_input.patch creates platform_driver for the touchscreen, not much is kept from the old.

The booting comes to "waiting to aquire IRQ" and then freezes. So it happens in one of these lines :

        printk(KERN_INFO "ts: waiting to request IRQ\n");
        error = request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
                        IRQF_DISABLED, "HP6XX Touchscreen Driver", pdev);

You need to track down exactly why the system is freezing. Some recommendations:

- Figure out how the device is hooked up to the processor. IRQn? IRLn? PINTn?
- Verify that you are using the correct IRQ number by calculating it from the vector number.
- Add a printk in the interrupt handler (hp680_ts_interrupt), see if you get any printouts.
- Is the interrupt shared with someone else? Disable that user and try again.
- Add/modify the irq demuxer in the machvec (.mv_irq_demux) to print out all irqs.
- Remove as many working devices as possible from your kernel and try again.
- Check that the interrupt sensing is correct. Is it level triggered? Active high? Edge triggered?
- Make sure the mask and priority bit fields are correct in the cpu-specific INTC tables.

Good luck!

/ magnus

#4 lore raw
In reply to Kristoffer Ericson
Quoted 8 lines · On Fri, 8 Feb 2008 11:57:07 +0900 "Magnus Damm" <[email protected]> wrote:

Hi Kristoffer,

Quoted 4 lines · Kristoffer Ericson

Greetings,

These patches are against vanilla 2.6.24, but should apply cleanly to linux-2.6 also. hp6xx_ts_input.patch creates platform_driver for the touchscreen, not much is kept from the old.

Quoted 8 lines
Quoted 5 lines

The booting comes to "waiting to aquire IRQ" and then freezes. So it happens in one of these lines :

        printk(KERN_INFO "ts: waiting to request IRQ\n");
        error = request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
                        IRQF_DISABLED, "HP6XX Touchscreen Driver", pdev);

You need to track down exactly why the system is freezing. Some recommendations:

I added some printk's into the interrupt and when I startup I end up with a massive loop of those printk's. Atleast its not frozen :)

However, one would think that it should continue after awhile (with the boot process) but it
keeps looping. The standard interrupt handler should disable -> enable the interrupt before and after interrupt is done?

Quoted 1 line

- Figure out how the device is hooked up to the processor. IRQn? IRLn? PINTn?

IRQ3 I believe

Quoted 2 lines

- Verify that you are using the correct IRQ number by calculating it from the vector number.

IRQ4 has irq 36 and this is IRQ3 so it should have 35. IRQ4 = vect(0x680) and IRQ3 = vect(0x660) so should be right.

Quoted 2 lines

- Add a printk in the interrupt handler (hp680_ts_interrupt), see if you get any printouts.

massive endless printouts.

Quoted 1 line

- Is the interrupt shared with someone else? Disable that user and try again.

Only user.

Quoted 2 lines

- Add/modify the irq demuxer in the machvec (.mv_irq_demux) to print out all irqs.

This IRQ should be handled by the standard mask_ack/enable/disable system and not by hd64461 ones.

Quoted 8 lines

- Remove as many working devices as possible from your kernel and try again.
- Check that the interrupt sensing is correct. Is it level triggered? Active high? Edge triggered?
- Make sure the mask and priority bit fields are correct in the cpu-specific INTC tables.

Good luck!

Thx!

Quoted 1 line

/ magnus

#5 lore raw
In reply to Kristoffer Ericson

Greetings,

It does indeed freeze at request_irq() (added some printk's). I've tried to conclude if its due to any IRQ3 changes, but feels doubtful since it worked in the past. Also, when it was a device driver it atleast booted even though the driver didn't work.

Test IRQ3 in all modes and nada (low level, falling, rising). Also tried to remove most of interrupt content but nothing changed. The interrupt of the touchscreen just loops forever, so any printk's I add will just do the same.

My best guess atm is that the inits (hp6xx / irq / touchscreen) somehow collide and thats why it atleast booted when it was an device driver.

What would happen if request IRQ would try to grab IRQ3 before plat_irq_setup_pins had started? Could it look anything like this?

Quoted 33 lines · On Fri, 8 Feb 2008 11:57:07 +0900 "Magnus Damm" <[email protected]> wrote:

Hi Kristoffer,

Quoted 9 lines · Kristoffer Ericson

Greetings,

These patches are against vanilla 2.6.24, but should apply cleanly to linux-2.6 also. hp6xx_ts_input.patch creates platform_driver for the touchscreen, not much is kept from the old.

The booting comes to "waiting to aquire IRQ" and then freezes. So it happens in one of these lines :

        printk(KERN_INFO "ts: waiting to request IRQ\n");
        error = request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
                        IRQF_DISABLED, "HP6XX Touchscreen Driver", pdev);

You need to track down exactly why the system is freezing. Some recommendations:

- Figure out how the device is hooked up to the processor. IRQn? IRLn? PINTn?
- Verify that you are using the correct IRQ number by calculating it from the vector number.
- Add a printk in the interrupt handler (hp680_ts_interrupt), see if you get any printouts.
- Is the interrupt shared with someone else? Disable that user and try again.
- Add/modify the irq demuxer in the machvec (.mv_irq_demux) to print out all irqs.
- Remove as many working devices as possible from your kernel and try again.
- Check that the interrupt sensing is correct. Is it level triggered? Active high? Edge triggered?
- Make sure the mask and priority bit fields are correct in the cpu-specific INTC tables.

Good luck!

/ magnus

#6 lore raw
In reply to Kristoffer Ericson
Quoted 15 lines · Kristoffer Ericson
Quoted 13 lines · On Fri, 8 Feb 2008 11:57:07 +0900 "Magnus Damm" <[email protected]> wrote:
Quoted 10 lines · Kristoffer Ericson

These patches are against vanilla 2.6.24, but should apply cleanly to linux-2.6 also. hp6xx_ts_input.patch creates platform_driver for the touchscreen, not much is kept from the old.

The booting comes to "waiting to aquire IRQ" and then freezes. So it happens in one of these lines :

        printk(KERN_INFO "ts: waiting to request IRQ\n");
        error = request_irq(HP680_TS_IRQ, hp680_ts_interrupt,
                        IRQF_DISABLED, "HP6XX Touchscreen Driver", pdev);
Quoted 6 lines
Quoted 2 lines

You need to track down exactly why the system is freezing. Some recommendations:

I added some printk's into the interrupt and when I startup I end up with a massive loop of those printk's. Atleast its not frozen :)

From the sounds of it the IRQ is being enabled and not being acked correctly. The behaviour you describe is generally what happens with unacked level IRQs that remain asserted.

Do any of the other IRQ0-IRQ7 IRQs work properly for you on hp6xx? Compare with before and after the INTC changes, and double check your pin setup.