This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Power Switch

Other Parts Discussed in Thread: AM3517, AM3874

I want to cut power to our AM3874 (currently testing with AM3517) after a shutdown much like a PC would.  I would have a GPIO configured for this task.  What should I modify in Linux to make this work?

Currently, issuing "shutdown -h now" results in a somewhat broken shutdown procedure (init scripts not running right or in the wrong order) and then a "system halted" message.  I want this to end in powering off the system.  If I must do this with a final init script, I suppose I could, but I figured there should be a more elegant way.

Of course, its not like ACPI is used on these embedded CPUs...

Any ideas?

  • I know this is a stale post, but were you ever able to resolve this issue?  I am trying to do the exact same thing on an am3517 based board.  I have a gpio that goes to a power management ic that I want to tell it to cut my power off when it is safe.  Right now my system just halts but remains on.

  • I found that you can have your shutdown code executed by giving a point to your function to pm_power_off in your board file.  Something like:

    static void my_power_off(void){

       //  Do your custom GPIO stuff here

    }

    static void __init myBoard_init(void){

       pm_power_off = my_power_off;

    }

    If you look at kernel/sys.c in your sources you can see that if pm_power_off is not assigned a value, the kernel will change a power off command into a halt command.  That is why you get "System Halted" even though you sent a shutdown.  Once pm_power_off points to a function it will be called at the end of the kernel shutdown procedure.

    This is working well for me, in that my function is getting called.  But, I am having trouble setting the GPIO.  I'll make my own post with that issue, but I wanted to close the loop on this one.

  • Hello,

    My implementation was more crude, but also works.  Check your init scripts and you will find a halt script which gives the final halt command.  Just before this command, I toggle the needed GPIO line.  Just make sure you have safely synced and unmounted your filesystems before power down (usually this is done in other shutdown scripts, but some of mine were broken).

    To do this, I exposed the gpio class in sysfs.  When this is done, all gpio numbers assigned in your board (platform) code should be exposed in sysfs.  It is pretty straight forward to send the needed command to sysfs (echo "..." >> /sys/class/...).

    If you need the actual command, I can look it up next week (don't have my platform setup right now).

  • David,

    Thanks for the reply.  I'm glad you were able to solve this issue as well.  My method seems to be working now so I'm going to stick with it.  (I had an additional hardware issue preventing me from pulling down the GPIO).  I may consider exposing the gpio to sysfs as well so that critical software in my embedded system has the capability to shut off the system in an emergency.

    Thanks,

    Sean