lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAASgrz0oG8-dnCai6_EF+MVnSjpztXP4b_ZOHorn6FZDdEL6pg@mail.gmail.com>
Date:	Wed, 27 Aug 2014 10:58:20 -0700
From:	David Riley <davidriley@...gle.com>
To:	Olof Johansson <olof@...om.net>
Cc:	Sebastian Reichel <sre@...nel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>,
	Guenter Roeck <linux@...ck-us.net>,
	Rob Herring <robh+dt@...nel.org>,
	Pawel Moll <pawel.moll@....com>,
	Mark Rutland <mark.rutland@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	Grant Likely <grant.likely@...aro.org>,
	Arnd Bergmann <arnd@...db.de>,
	Anton Vorontsov <anton@...msg.org>,
	Marc Carino <marc.ceeeee@...il.com>,
	Anders Berg <anders.berg@....com>,
	Laxman Dewangan <ldewangan@...dia.com>,
	Ivan Khoronzhuk <ivan.khoronzhuk@...com>,
	Maxime Ripard <maxime.ripard@...e-electrons.com>,
	Haojian Zhuang <haojian.zhuang@...aro.org>,
	Jamie Lentin <jm@...tin.co.uk>,
	Doug Anderson <dianders@...omium.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>
Subject: Re: [PATCH v1 1/1] power: Add simple gpio-restart driver

Hi Olof,

On Tue, Aug 26, 2014 at 7:14 PM, Olof Johansson <olof@...om.net> wrote:
> Hi,
>
>
>
> On Tue, Aug 26, 2014 at 4:45 PM, David Riley <davidriley@...omium.org> wrote:
>> This driver registers a restart handler to set a GPIO line high/low
>> to reset a board based on devicetree bindings.
>>
>> Signed-off-by: David Riley <davidriley@...omium.org>
>> ---
>>  .../devicetree/bindings/gpio/gpio-restart.txt      |  48 +++++++
>>  drivers/power/reset/Kconfig                        |   8 ++
>>  drivers/power/reset/Makefile                       |   1 +
>>  drivers/power/reset/gpio-restart.c                 | 142 +++++++++++++++++++++
>>  4 files changed, 199 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/gpio/gpio-restart.txt
>>  create mode 100644 drivers/power/reset/gpio-restart.c
>>
>> diff --git a/Documentation/devicetree/bindings/gpio/gpio-restart.txt b/Documentation/devicetree/bindings/gpio/gpio-restart.txt
>> new file mode 100644
>> index 0000000..7cd58788
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/gpio/gpio-restart.txt
>> @@ -0,0 +1,48 @@
>> +Driver a GPIO line that can be used to restart the system as a
>> +restart handler.
>> +
>> +The driver supports both level triggered and edge triggered power off.
>> +At driver load time, the driver will request the given gpio line and
>> +install a restart handler. If the optional properties 'input' is
>> +not found, the GPIO line will be driven in the inactive state.
>> +Otherwise its configured as an input.
>> +
>> +When do_kernel_restart is called the various restart handlers will be tried
>> +in order.
>
> The above sentence documents the kernel behavior, not the hardware
> description/binding.

I've cleaned this up.

>
>> +The gpio is configured as an output, and drive active, so
>> +triggering a level triggered power off condition. This will also cause an
>> +inactive->active edge condition, so triggering positive edge triggered
>> +power off.
>
>> + After a delay of 100ms, the GPIO is set to inactive, thus
>> +causing an active->inactive edge, triggering negative edge triggered power
>> +off. After another 100ms delay the GPIO is driver active again. If the
>> +power is still on and the CPU still running after a 3000ms delay, a
>> +WARN_ON(1) is emitted.
>
> It's possible that this behavior is inadequate for some hardware in
> the future -- if so they can amend the binding (i.e. this comment is
> an attempt at preemptive bikeshed avoidance :)

Changed to be configurable at the request of Guenter.

>> +
>> +Required properties:
>> +- compatible : should be "gpio-restart".
>> +- gpios : The GPIO to set high/low, see "gpios property" in
>> +  Documentation/devicetree/bindings/gpio/gpio.txt. If the pin should be
>> +  low to power down the board set it to "Active Low", otherwise set
>> +  gpio to "Active High".
>> +
>> +Optional properties:
>> +- input : Initially configure the GPIO line as an input. Only reconfigure
>> +  it to an output when the machine_restart function is called. If this optional
>> +  property is not specified, the GPIO is initialized as an output in its
>> +  inactive state.
>
> Isn't this the same as configuring the pin as tristate? I think that
> should probably be controlled by pinmux setup instead?

I think this still needs to be usable independently of pinctrl and it
keeps consistency with gpio-poweroff.

>
>> +- priority : A priority ranging from 0 to 255 (default 128) according to
>> +  the following guidelines:
>> +       0:      Restart handler of last resort, with limited restart
>> +               capabilities
>> +       128:    Default restart handler; use if no other restart handler is
>> +               expected to be available, and/or if restart functionality is
>> +               sufficient to restart the entire system
>> +       255:    Highest priority restart handler, will preempt all other
>> +               restart handlers
>
> This is sort of leaking linux implementation, but it's also a useful
> feature to have in the description. It seems sane enough to me to use.
>
>> +
>> +Examples:
>> +
>> +gpio-restart {
>> +       compatible = "gpio-restart";
>> +       gpios = <&gpio 4 0>;
>> +       priority = /bits/ 8 <200>;
>
> I think it makes sense to just have this as a regular cell instead of
> doing an 8-bit value -- it's how we normally handle these elsewhere.

Done.

>
>
> -Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ