LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 03-29-2012, 12:46 PM   #1
engr04
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?

Thanks,
Nate
 
Old 03-29-2012, 01:43 PM   #2
jhwilliams
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:

Documentation/power/devices.txt
Documentation/gpio.txt

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, 02:13 PM   #3
engr04
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:

Quote:
#define TOUCH_IRQ_PINAT91_PIN_PB10
gpio_request(TOUCH_IRQ_PIN, "PB10");
gpio_direction_input(TOUCH_IRQ_PIN);
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))
schedule_work(&mywork);
return IRQ_HANDLED;
}

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 02:23 PM. Reason: Accidentally posted when using tab key :)
 
Old 04-06-2012, 09:06 PM   #4
engr04
LQ Newbie
 
Registered: Mar 2012
Posts: 21

Original Poster
Rep: Reputation: Disabled
Talking

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.
 
  


Reply



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 03:57 PM
pm-suspend vs. alternatives. gnome vs. enlightenment suspend. mkultra329 Linux - Newbie 1 02-19-2010 10:56 AM
how to configure gnome suspend and hibernate? xaos5 Debian 6 02-19-2010 10:36 AM
Using GPIO (from kernel GPIO support) in MY application DannyGilbert Linux - Kernel 2 03-16-2009 07:52 AM
Plz explain Suspend to Disk and Suspend to Ram pkhera_2001 Linux - Newbie 2 02-18-2008 07:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 11:37 AM.

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