I asked Robert how the pwr button is processed and interestingly it is done via 
udev and systemd. Also, there is some new code going mainstream for the pwr 
button and battery charger. Perhaps you can implement the timer delay via a 
custom systemd service. Here is what Robert sent me:

Oh this is finally getting upstreamed:

https://www.spinics.net/lists/linux-omap/msg127184.html 
<https://www.spinics.net/lists/linux-omap/msg127184.html>

I need to switch to their version, vs our 3.8.13 erra hack that's been forward 
ported for years. ;)

Behind the scenes's that patch is reporting a key-event to systemd...

https://github.com/systemd/systemd/blob/09541e49ebd17b41482e447dd8194942f39788c0/src/login/70-power-switch.rules#L13
 
<https://github.com/systemd/systemd/blob/09541e49ebd17b41482e447dd8194942f39788c0/src/login/70-power-switch.rules#L13>

Regards,
John




> On Apr 17, 2016, at 11:06 PM, William Hermans <yyrk...@gmail.com> wrote:
> 
> There is no timer in that code. The timer would have to be added, and careful 
> consideration would have to be given to exactly how that was implemented.
> 
> So in other words, you would, or should write a completely new kernel module, 
> that is meant to replace what already exists - As an option.
> 
> On Sun, Apr 17, 2016 at 10:25 PM, evilwulfie <evilwul...@gmail.com 
> <mailto:evilwul...@gmail.com>> wrote:
> Where in the code do you set that timer ?
> 
> 
> 
> On 4/17/2016 7:50 PM, John Syne wrote:
>> One more thing, the power down sequence uses the RTC framework (described 
>> earlier in this thread), so it will be possible to set a timer for the 
>> shutdown and the wait for the power to return event to cancel the timer. If 
>> the power on event does not occur, the shutdown will occur.
>> 
>> Regards,
>> John
>> 
>> 
>> 
>> 
>>> On Apr 17, 2016, at 7:18 PM, evilwulfie < 
>>> <mailto:evilwul...@gmail.com>evilwul...@gmail.com 
>>> <mailto:evilwul...@gmail.com>> wrote:
>>> 
>>> Interesting.  Too bad if you want the battery to act as a UPS it cant some 
>>> how notify the kernel that AC has been removed
>>> and have a routine to just chill a while to see if power comes back.
>>> 
>>> Be nice to have a variable that is user settable for the time between loss 
>>> of AC and shutdown.
>>> 
>>> As it is now it sees the AC removed, shuts down and no easy way to restart 
>>> on power restored. Requiring some other IC to monitor power 
>>> and then press the pwr_but to restart the processor.
>>> 
>>> 
>>> 
>>> On 4/17/2016 7:10 PM, John Syne wrote:
>>>> Yep, it is in the BB kernel:
>>>> 
>>>> https://github.com/RobertCNelson/bb-kernel/blob/am33x-v4.1/patches/beaglebone/dts/0006-tps65217-Enable-KEY_POWER-press-on-AC-loss-PWR_BUT.patch
>>>>  
>>>> <https://github.com/RobertCNelson/bb-kernel/blob/am33x-v4.1/patches/beaglebone/dts/0006-tps65217-Enable-KEY_POWER-press-on-AC-loss-PWR_BUT.patch>
>>>> 
>>>> So again, on line 164 is the Interrupt routing. It is this line:
>>>> 
>>>> +          input_report_key(tps->pwr_but, KEY_POWER,
>>>> 
>>>> +                          ~status_reg & TPS65217_STATUS_ACPWR);
>>>> that send a power button pressed as an input key when the AC 5V power is 
>>>> removed. 
>>>> 
>>>> Regards,
>>>> John
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> On Apr 17, 2016, at 4:52 PM, William Hermans <yyrk...@gmail.com 
>>>>> <mailto:yyrk...@gmail.com>> wrote:
>>>>> 
>>>>> The real reason why our source trees do not match up. My source tree is 
>>>>> based on 4.1.x, and yours seems to be 3.8.x. The patch you showed above 
>>>>> would probably botch up my source tree . . .
>>>>> 
>>>>> On Sun, Apr 17, 2016 at 4:33 PM, William Hermans < 
>>>>> <mailto:yyrk...@gmail.com>yyrk...@gmail.com <mailto:yyrk...@gmail.com>> 
>>>>> wrote:
>>>>> Yeah I recognize that code from source code not written by TI employees. 
>>>>> The file is called tps65217_charger.c, and is written by an employee of 
>>>>> another company.
>>>>> 
>>>>> Anyway, I think we're going to blow this off. The idea was to wait around 
>>>>> without power for 5 minutes, to see if power comes back up. Before 
>>>>> issuing a shutdown. Then, on the power up end, using a simple R/C circuit 
>>>>> to ramp up voltage to 5v over a specific time period.
>>>>> 
>>>>> 
>>> 
>>> 
>>>  
>>> <https://www.avast.com/en-us/lp-safe-emailing-2109?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2109-v2-a>
>>>   Virus-free. www.avast.com 
>>> <https://www.avast.com/en-us/lp-safe-emailing-2109?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2109-v2-a>
>>> 
>>> -- 
>>> For more options, visit http://beagleboard.org/discuss 
>>> <http://beagleboard.org/discuss>
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "BeagleBoard" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to beagleboard+unsubscr...@googlegroups.com 
>>> <mailto:beagleboard+unsubscr...@googlegroups.com>.
>>> To view this discussion on the web visit  
>>> <https://groups.google.com/d/msgid/beagleboard/571443FC.6020505%40gmail.com?utm_medium=email&utm_source=footer>https://groups.google.com/d/msgid/beagleboard/571443FC.6020505%40gmail.com
>>>  
>>> <https://groups.google.com/d/msgid/beagleboard/571443FC.6020505%40gmail.com>.
>>> For more options, visit https://groups.google.com/d/optout 
>>> <https://groups.google.com/d/optout>.
>> 
>> -- 
>> For more options, visit http://beagleboard.org/discuss 
>> <http://beagleboard.org/discuss>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BeagleBoard" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to beagleboard+unsubscr...@googlegroups.com 
>> <mailto:beagleboard+unsubscr...@googlegroups.com>.
>> To view this discussion on the web visit  
>> <https://groups.google.com/d/msgid/beagleboard/2CC5F218-6933-45E8-8B84-2CEE08263AF5%40gmail.com?utm_medium=email&utm_source=footer>https://groups.google.com/d/msgid/beagleboard/2CC5F218-6933-45E8-8B84-2CEE08263AF5%40gmail.com
>>  
>> <https://groups.google.com/d/msgid/beagleboard/2CC5F218-6933-45E8-8B84-2CEE08263AF5%40gmail.com>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
>  
> <https://www.avast.com/en-us/lp-safe-emailing-2109?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2109-v2-a>
>     Virus-free. www.avast.com 
> <https://www.avast.com/en-us/lp-safe-emailing-2109?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2109-v2-a>
> 
> -- 
> For more options, visit http://beagleboard.org/discuss 
> <http://beagleboard.org/discuss>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to beagleboard+unsubscr...@googlegroups.com 
> <mailto:beagleboard+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beagleboard/57146FB7.5000301%40gmail.com 
> <https://groups.google.com/d/msgid/beagleboard/57146FB7.5000301%40gmail.com?utm_medium=email&utm_source=footer>.
> 
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> For more options, visit http://beagleboard.org/discuss 
> <http://beagleboard.org/discuss>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to beagleboard+unsubscr...@googlegroups.com 
> <mailto:beagleboard+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beagleboard/CALHSORqGgChYUiW8na9wJqDQNW3_tOXn4YW4Rrhqe0UyCzDGWg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/beagleboard/CALHSORqGgChYUiW8na9wJqDQNW3_tOXn4YW4Rrhqe0UyCzDGWg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/8482E576-E05F-4B45-8F30-87B0AFA8D211%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to