All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
@ 2010-09-15 16:29 Anti Sullin
  2010-09-15 21:28 ` Steve Sakoman
  0 siblings, 1 reply; 6+ messages in thread
From: Anti Sullin @ 2010-09-15 16:29 UTC (permalink / raw)
  To: linux-omap; +Cc: Tony Lindgren, Felipe Balbi, David Brownell

I was not getting OTG USB vbus/id pin change interrupts on Gumstix Overo
and the reason was a mis-configured irq. I added some more checks to avoid
having a non-bootable kernel on boards with bootloaders that have wrong pinmux.
The changes of twl4030 should be tested on other boards too.

---
Gumstix Overo has TPS65950 (TWL4030) IRQ1 connected to GPIO112.

This patch fixes the TWL4030 IRQ mapping. The TWL4030 IRQ is used to signal USB OTG
connection events. If this does not work, the USB OTG and peripheral modes
do not work.

GPIO112 mux is wrong in bootloader, too. In case the board uses an older
bootloader, we'll try to re-mux it in kernel (requires CONFIG_OMAP_MUX).

TWL4030 IRQ1 requires pull-up to be activated on GPIO112. If it is not
(bootloader did not do it and kernel has CONFIG_OMAP_MUX disabled)
the kernel would have a stuck interrupt. To avoid freeze, spurious interrupt
detection is added to TWL4030.

Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee>
---
diff -pur linux-2.6.34/arch/arm/mach-omap2/board-overo.c linux-2.6.34-ok/arch/arm/mach-omap2/board-overo.c
--- linux-2.6.34/arch/arm/mach-omap2/board-overo.c	2010-05-17 00:17:36.000000000 +0300
+++ linux-2.6.34-ok/arch/arm/mach-omap2/board-overo.c	2010-09-14 19:49:00.000000000 +0300
@@ -52,6 +52,7 @@
 
 #define OVERO_GPIO_BT_XGATE	15
 #define OVERO_GPIO_W2W_NRESET	16
+#define OVERO_GPIO_TPS65950_IRQ	112
 #define OVERO_GPIO_PENDOWN	114
 #define OVERO_GPIO_BT_NRESET	164
 #define OVERO_GPIO_USBH_CPEN	168
@@ -353,7 +354,7 @@ static struct i2c_board_info __initdata 
 	{
 		I2C_BOARD_INFO("tps65950", 0x48),
 		.flags = I2C_CLIENT_WAKE,
-		.irq = INT_34XX_SYS_NIRQ,
+		.irq = OMAP_GPIO_IRQ(OVERO_GPIO_TPS65950_IRQ),
 		.platform_data = &overo_twldata,
 	},
 };
@@ -422,6 +423,21 @@ static struct omap_musb_board_data musb_
 static void __init overo_init(void)
 {
 	omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
+
+	/* Mux GPIO112 to pull-up input. In case bad bootloader is used,
+	 * override mux settings manually here.
+	 * Requires CONFIG_OMAP_MUX! */
+	omap_mux_set_gpio(OMAP_MUX_MODE4 | OMAP_PIN_INPUT_PULLUP,
+			OVERO_GPIO_TPS65950_IRQ);
+
+	if ((gpio_request(OVERO_GPIO_TPS65950_IRQ, "TPS65950_IRQ") == 0) &&
+	    (gpio_direction_input(OVERO_GPIO_TPS65950_IRQ) == 0)) {
+		gpio_export(OVERO_GPIO_TPS65950_IRQ, 0);
+	} else {
+		printk(KERN_ERR "could not obtain gpio for TPS65950 IRQ\n");
+		return;
+	}
+
 	overo_i2c_init();
 	platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
 	omap_serial_init();
diff -pur linux-2.6.34/drivers/mfd/twl4030-irq.c linux-2.6.34-ok/drivers/mfd/twl4030-irq.c
--- linux-2.6.34/drivers/mfd/twl4030-irq.c	2010-05-17 00:17:36.000000000 +0300
+++ linux-2.6.34-ok/drivers/mfd/twl4030-irq.c	2010-09-14 19:50:25.000000000 +0300
@@ -312,6 +312,14 @@ static int twl4030_irq_thread(void *data
 			continue;
 		}
 
+		/* Check for spurious interrupts */
+		if (!pih_isr) {
+			printk(KERN_ERR "Spurious TWL4030 interrupt"
+					" detected.  Terminating %s.\n",
+					__func__);
+			break;
+		}
+
 		/* these handlers deal with the relevant SIH irq status */
 		local_irq_disable();
 		for (module_irq = twl4030_irq_base;
@@ -832,7 +840,7 @@ int twl4030_init_irq(int irq_num, unsign
 
 	init_completion(&irq_event);
 
-	status = request_irq(irq_num, handle_twl4030_pih, IRQF_DISABLED,
+	status = request_irq(irq_num, handle_twl4030_pih, IRQF_TRIGGER_LOW | IRQF_DISABLED,
 				"TWL4030-PIH", &irq_event);
 	if (status < 0) {
 		pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status);



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
  2010-09-15 16:29 [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection) Anti Sullin
@ 2010-09-15 21:28 ` Steve Sakoman
  2010-09-16  6:07   ` Felipe Balbi
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Sakoman @ 2010-09-15 21:28 UTC (permalink / raw)
  To: Anti Sullin; +Cc: linux-omap, Tony Lindgren, Felipe Balbi, David Brownell

On Wed, Sep 15, 2010 at 9:29 AM, Anti Sullin <anti.sullin@artecdesign.ee> wrote:
> I was not getting OTG USB vbus/id pin change interrupts on Gumstix Overo
> and the reason was a mis-configured irq. I added some more checks to avoid
> having a non-bootable kernel on boards with bootloaders that have wrong pinmux.
> The changes of twl4030 should be tested on other boards too.
>
> ---
> Gumstix Overo has TPS65950 (TWL4030) IRQ1 connected to GPIO112.

I don't think that this change should be made.

>From what I understand from my discussions with Gumstix, early
versions of the Overo COM used GPIO112 as indicated above.

However all fab revisions >=2516 use GPIO0, so the code is correct for
current and future versions of Overo COMs (as is the bootloader
pinmuxing).

In fact, future versions of Overo will use GPIO112 for a revision ID.

Not an ideal situation, but I think we should leave things as they are
since it matches current and future production.

People with older boards will certainly need to use this patch to get
vbus/id interrupts.

Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
  2010-09-15 21:28 ` Steve Sakoman
@ 2010-09-16  6:07   ` Felipe Balbi
  2010-09-16 12:56     ` Steve Sakoman
  0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2010-09-16  6:07 UTC (permalink / raw)
  To: Steve Sakoman
  Cc: Anti Sullin, linux-omap, Tony Lindgren, Felipe Balbi, David Brownell

On Wed, Sep 15, 2010 at 04:28:57PM -0500, Steve Sakoman wrote:
>On Wed, Sep 15, 2010 at 9:29 AM, Anti Sullin <anti.sullin@artecdesign.ee> wrote:
>> I was not getting OTG USB vbus/id pin change interrupts on Gumstix Overo
>> and the reason was a mis-configured irq. I added some more checks to avoid
>> having a non-bootable kernel on boards with bootloaders that have wrong pinmux.
>> The changes of twl4030 should be tested on other boards too.
>>
>> ---
>> Gumstix Overo has TPS65950 (TWL4030) IRQ1 connected to GPIO112.
>
>I don't think that this change should be made.
>
>>From what I understand from my discussions with Gumstix, early
>versions of the Overo COM used GPIO112 as indicated above.
>
>However all fab revisions >=2516 use GPIO0, so the code is correct for
>current and future versions of Overo COMs (as is the bootloader
>pinmuxing).
>
>In fact, future versions of Overo will use GPIO112 for a revision ID.
>
>Not an ideal situation, but I think we should leave things as they are
>since it matches current and future production.
>
>People with older boards will certainly need to use this patch to get
>vbus/id interrupts.

it would be better to get all boards working. Can't you use
ATAG_REVISION or system_rev to differentiate the board revisions and
change gpio number accordingly ??

-- 
balbi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
  2010-09-16  6:07   ` Felipe Balbi
@ 2010-09-16 12:56     ` Steve Sakoman
  2010-09-16 17:40       ` Tony Lindgren
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Sakoman @ 2010-09-16 12:56 UTC (permalink / raw)
  To: balbi
  Cc: Anti Sullin, linux-omap, Tony Lindgren, Felipe Balbi, David Brownell

On Wed, Sep 15, 2010 at 11:07 PM, Felipe Balbi <balbi@ti.com> wrote:
> On Wed, Sep 15, 2010 at 04:28:57PM -0500, Steve Sakoman wrote:
>>
>> On Wed, Sep 15, 2010 at 9:29 AM, Anti Sullin <anti.sullin@artecdesign.ee>
>> wrote:
>>>
>>> I was not getting OTG USB vbus/id pin change interrupts on Gumstix Overo
>>> and the reason was a mis-configured irq. I added some more checks to
>>> avoid
>>> having a non-bootable kernel on boards with bootloaders that have wrong
>>> pinmux.
>>> The changes of twl4030 should be tested on other boards too.
>>>
>>> ---
>>> Gumstix Overo has TPS65950 (TWL4030) IRQ1 connected to GPIO112.
>>
>> I don't think that this change should be made.
>>
>>> From what I understand from my discussions with Gumstix, early
>>
>> versions of the Overo COM used GPIO112 as indicated above.
>>
>> However all fab revisions >=2516 use GPIO0, so the code is correct for
>> current and future versions of Overo COMs (as is the bootloader
>> pinmuxing).
>>
>> In fact, future versions of Overo will use GPIO112 for a revision ID.
>>
>> Not an ideal situation, but I think we should leave things as they are
>> since it matches current and future production.
>>
>> People with older boards will certainly need to use this patch to get
>> vbus/id interrupts.
>
> it would be better to get all boards working. Can't you use
> ATAG_REVISION or system_rev to differentiate the board revisions and
> change gpio number accordingly ??

Agreed.  Gumstix doesn't provide an easy way of determining the layout
revision via software (the boards are marked with the rev number, but
that doesn't do much good!).

I'm investigating methods to figure this out, but haven't yet found
anything reliable.  When I do I'll post a patch.

Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
  2010-09-16 12:56     ` Steve Sakoman
@ 2010-09-16 17:40       ` Tony Lindgren
  2010-09-16 17:46         ` Steve Sakoman
  0 siblings, 1 reply; 6+ messages in thread
From: Tony Lindgren @ 2010-09-16 17:40 UTC (permalink / raw)
  To: Steve Sakoman
  Cc: balbi, Anti Sullin, linux-omap, Felipe Balbi, David Brownell

* Steve Sakoman <sakoman@gmail.com> [100916 05:48]:
> 
> Agreed.  Gumstix doesn't provide an easy way of determining the layout
> revision via software (the boards are marked with the rev number, but
> that doesn't do much good!).

Unless you use the camera interface during early init to detect that
revision printed on the circuit board ;)
 
> I'm investigating methods to figure this out, but haven't yet found
> anything reliable.  When I do I'll post a patch.

How about add something to u-boot that allows setenv system_rev in
u-boot? Maybe it already has this feature as system_rev is arm-linux
generic atag.

Regards,

Tony

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection)
  2010-09-16 17:40       ` Tony Lindgren
@ 2010-09-16 17:46         ` Steve Sakoman
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Sakoman @ 2010-09-16 17:46 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: balbi, Anti Sullin, linux-omap, Felipe Balbi, David Brownell

On Thu, Sep 16, 2010 at 10:40 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Steve Sakoman <sakoman@gmail.com> [100916 05:48]:
>>
>> Agreed.  Gumstix doesn't provide an easy way of determining the layout
>> revision via software (the boards are marked with the rev number, but
>> that doesn't do much good!).
>
> Unless you use the camera interface during early init to detect that
> revision printed on the circuit board ;)

That was my first idea too :-)

>> I'm investigating methods to figure this out, but haven't yet found
>> anything reliable.  When I do I'll post a patch.
>
> How about add something to u-boot that allows setenv system_rev in
> u-boot? Maybe it already has this feature as system_rev is arm-linux
> generic atag.

The hard part is creating the code to figure out how the board is wired :-)

I have some promising approaches, but nothing working yet.  Once that
is done the rest is easy!

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-16 17:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-15 16:29 [PATCH] overo twl4030: fix twl4030 IRQ (used for usb otg detection) Anti Sullin
2010-09-15 21:28 ` Steve Sakoman
2010-09-16  6:07   ` Felipe Balbi
2010-09-16 12:56     ` Steve Sakoman
2010-09-16 17:40       ` Tony Lindgren
2010-09-16 17:46         ` Steve Sakoman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.