Linux RTC
 help / color / mirror / Atom feed
* [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time?
       [not found] <CAJ+vNU3V-i2uJTpyE_swqjCvjVr+-j1+jjp+WuZLDA8Os74y=g@mail.gmail.com>
@ 2015-10-20 21:21 ` Sebastian Reichel
  2015-10-24  2:12   ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Reichel @ 2015-10-20 21:21 UTC (permalink / raw)
  To: Tim Harvey; +Cc: linux-pm, rtc-linux

[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]

Hi,

On Tue, Oct 20, 2015 at 08:12:09AM -0700, Tim Harvey wrote:
> There is a system controller [1] on a set of embedded boards I support
> that allows disabling the board's primary power supply. It can disable
> it (until a physical pushbutton event occurs) and/or disable it for a
> certain number of seconds (up to 2^16 seconds).
> 
> I've been in the process of writing a mfd driver to fully support this
> device and I'm a bit stumped on how to handle the power management
> capabilities.
> 
> What is the correct API for this type of device in sysfs? I'm thinking
> it needs a power-supply class driver, but after looking over the docs
> and code I'm not seeing examples of similar devices. Can anyone point
> me to an example or provide some suggestions?

Usually this is an RTC feature exposed as wakealarm. See for example
this article for the description of the userspace interface:

https://www.linux.com/learn/docs/672849-wake-up-linux-with-an-rtc-alarm-clock

-- Sebastian

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time?
  2015-10-20 21:21 ` [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time? Sebastian Reichel
@ 2015-10-24  2:12   ` Alexandre Belloni
  2015-10-27 14:55     ` Tim Harvey
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2015-10-24  2:12 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: Tim Harvey, linux-pm, rtc-linux

Hi,

On 20/10/2015 at 23:21:27 +0200, Sebastian Reichel wrote :
> Hi,
> 
> On Tue, Oct 20, 2015 at 08:12:09AM -0700, Tim Harvey wrote:
> > There is a system controller [1] on a set of embedded boards I support
> > that allows disabling the board's primary power supply. It can disable
> > it (until a physical pushbutton event occurs) and/or disable it for a
> > certain number of seconds (up to 2^16 seconds).
> > 
> > I've been in the process of writing a mfd driver to fully support this
> > device and I'm a bit stumped on how to handle the power management
> > capabilities.
> > 
> > What is the correct API for this type of device in sysfs? I'm thinking
> > it needs a power-supply class driver, but after looking over the docs
> > and code I'm not seeing examples of similar devices. Can anyone point
> > me to an example or provide some suggestions?
> 
> Usually this is an RTC feature exposed as wakealarm. See for example
> this article for the description of the userspace interface:
> 
> https://www.linux.com/learn/docs/672849-wake-up-linux-with-an-rtc-alarm-clock

Indeed, if you can set the time, then shutdown in two discreet steps,
then you can probably expose an alarm and a poweroff controller.
If there is only one step involved, then this will not fit well in any
subsystem but I guess it makes more sense to put it in the RTC
subsystem as it has all the utilities to handle dates and times.



-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time?
  2015-10-24  2:12   ` Alexandre Belloni
@ 2015-10-27 14:55     ` Tim Harvey
  2015-10-27 15:29       ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Harvey @ 2015-10-27 14:55 UTC (permalink / raw)
  To: Sebastian Reichel, Alexandre Belloni; +Cc: linux-pm, rtc-linux

On Fri, Oct 23, 2015 at 7:12 PM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Hi,
>
> On 20/10/2015 at 23:21:27 +0200, Sebastian Reichel wrote :
>> Hi,
>>
>> On Tue, Oct 20, 2015 at 08:12:09AM -0700, Tim Harvey wrote:
>> > There is a system controller [1] on a set of embedded boards I support
>> > that allows disabling the board's primary power supply. It can disable
>> > it (until a physical pushbutton event occurs) and/or disable it for a
>> > certain number of seconds (up to 2^16 seconds).
>> >
>> > I've been in the process of writing a mfd driver to fully support this
>> > device and I'm a bit stumped on how to handle the power management
>> > capabilities.
>> >
>> > What is the correct API for this type of device in sysfs? I'm thinking
>> > it needs a power-supply class driver, but after looking over the docs
>> > and code I'm not seeing examples of similar devices. Can anyone point
>> > me to an example or provide some suggestions?
>>
>> Usually this is an RTC feature exposed as wakealarm. See for example
>> this article for the description of the userspace interface:
>>
>> https://www.linux.com/learn/docs/672849-wake-up-linux-with-an-rtc-alarm-clock

Sebastian,

Thanks for the pointer - this device does have an RTC so the wakealarm
makes complete sense here.

>
> Indeed, if you can set the time, then shutdown in two discreet steps,
> then you can probably expose an alarm and a poweroff controller.
> If there is only one step involved, then this will not fit well in any
> subsystem but I guess it makes more sense to put it in the RTC
> subsystem as it has all the utilities to handle dates and times.
>
>

Alexandre,

The power-off process is a discrete step from setting the wakeup time.
By 'poweroff controller' I'm assuming you mean implement a
pm_power_off hook which makes sense.

While I'm at it it seems like implementing arm_pm_restart makes a lot
of sense as well as the device can toggle board power which should be
preferred over a chip-level reset.

I was looking for a standard userspace sysfs API in (ie
/sys/class/power?) that will call kernel_restart or kernel_power_off
but the only thing I've found is either the reboot syscall or sysrq (o
or b). Have I missed something or are these the expected userspace
API's for power-off/reset?

Thanks!

Tim

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

* Re: [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time?
  2015-10-27 14:55     ` Tim Harvey
@ 2015-10-27 15:29       ` Alexandre Belloni
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-10-27 15:29 UTC (permalink / raw)
  To: Tim Harvey; +Cc: Sebastian Reichel, linux-pm, rtc-linux

Hi,

On 27/10/2015 at 07:55:28 -0700, Tim Harvey wrote :
> The power-off process is a discrete step from setting the wakeup time.
> By 'poweroff controller' I'm assuming you mean implement a
> pm_power_off hook which makes sense.
> 
> While I'm at it it seems like implementing arm_pm_restart makes a lot
> of sense as well as the device can toggle board power which should be
> preferred over a chip-level reset.
> 

Sure, then you can probably make an MFD which is the proper way of
register one device in multiple susbsytems. I just happened to give a
talk on that topic:

http://free-electrons.com/pub/conferences/2015/elce/belloni-mfd-regmap-syscon/belloni-mfd-regmap-syscon.pdf

> I was looking for a standard userspace sysfs API in (ie
> /sys/class/power?) that will call kernel_restart or kernel_power_off
> but the only thing I've found is either the reboot syscall or sysrq (o
> or b). Have I missed something or are these the expected userspace
> API's for power-off/reset?

Yeah, I'm guessing this is the correct API, people usually use
halt/poweroff/shutdown/reboot which should all end up calling the reboot
system call.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

end of thread, other threads:[~2015-10-27 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CAJ+vNU3V-i2uJTpyE_swqjCvjVr+-j1+jjp+WuZLDA8Os74y=g@mail.gmail.com>
2015-10-20 21:21 ` [rtc-linux] Re: where in sysfs should I put the ability to power down a board for a specific time? Sebastian Reichel
2015-10-24  2:12   ` Alexandre Belloni
2015-10-27 14:55     ` Tim Harvey
2015-10-27 15:29       ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox