Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 03-29-2012, 01:46 PM   #1
LQ Newbie
Registered: Mar 2012
Posts: 21

Rep: Reputation: Disabled
Configure GPIO Wakup from Suspend

Hardware: Custom board based on at91sam9263ek

I'd like to be able to wakeup from standby using a GPIO pin.

I can currently enter standby mode and wake up by using the RTC:

#Standby for 60 seconds, then wake up
echo "" > /sys/class/rtc/rtc0/wakealarm
echo "+60" > /sys/class/rtc/rtc0/wakealarm
echo standby > /sys/power/state

How can I configure a GPIO Wakeup event from standby state? Is there a way to do this from user space, or does it need to be written into a driver?

Old 03-29-2012, 02:43 PM   #2
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
I would not advise trying to do this in user space. Do it the right way to begin with, as a kernel module/component.

Check out these bits of documentation in the Linux source tree if you haven't already:


Essentially, you need to:

- Register the input gpio
- Register an ISR for that GPIO via gpio_to_irq() and request_irq().
- Build out the power management operations as discussed in the above documentation.
- Arrange for yoru power management hooks to be called from the interrupt service routine
Old 03-29-2012, 03:13 PM   #3
LQ Newbie
Registered: Mar 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
jhwilliams - thanks for the reply.

It sounds like I'm already halfway there.

I have written a touchscreen driver that has an irq generated from a GPIO. Here's a few cutouts:

gpio_request(TOUCH_IRQ_PIN, "PB10");
request_irq(TOUCH_IRQ_PIN, read_interrupt, IRQF_SHARED,"touchScreenIRQ", INT_ID);

DECLARE_WORK( mywork, my_workqueue_handler);
static irqreturn_t read_interrupt(int irq, void *dev_id)
if (gpio_get_value(TOUCH_IRQ_PIN))

void my_workqueue_handler(void *arg)
//do interrupt work here
I'll read through the documentation you provided and post an update.

Last edited by engr04; 03-29-2012 at 03:23 PM. Reason: Accidentally posted when using tab key :)
Old 04-06-2012, 10:06 PM   #4
LQ Newbie
Registered: Mar 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled

I had some time to look into this tonight. "enable_irq_wake(TOUCH_IRQ_PIN);" did the trick.

To hook it in with /sys/devices/.../wakeup, device_may_wakeup can be used.

Thanks for the references.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
GPIO access on a Fujitsu Mini-ITX Industrial Mainboard, PCI Driver for GPIO mechatrix Linux - Embedded & Single-board computer 3 11-20-2011 04:57 PM
pm-suspend vs. alternatives. gnome vs. enlightenment suspend. mkultra329 Linux - Newbie 1 02-19-2010 11:56 AM
how to configure gnome suspend and hibernate? xaos5 Debian 6 02-19-2010 11:36 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 08:52 AM
Plz explain Suspend to Disk and Suspend to Ram pkhera_2001 Linux - Newbie 2 02-18-2008 08:23 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 12:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration