<br><br>On Tuesday, September 6, 2016, Scott Wood <<a href="mailto:scott.wood@nxp.com">scott.wood@nxp.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 09/06/2016 02:12 PM, Andy Fleming wrote:<br>
> Boards can implement power and reset functionality over gpio using<br>
> these drivers:<br>
>   drivers/power/reset/gpio-<wbr>poweroff.c<br>
>   drivers/power/reset/gpio-<wbr>restart.c<br>
><br>
> While not all corenet boards use gpio for power/reset, this<br>
> support can be added without interfering with boards that do not<br>
> use this functionality.<br>
><br>
> If a board's device tree has the related nodes, they are now probed.<br>
> Also, gpio-poweroff uses the global pm_power_off callback to implement<br>
> the shutdown. However, pm_power_off was not invoked when the kernel<br>
> halted, although that is usually the desired behavior. If the board<br>
> provides gpio power and reset support, it is reasonable to assume that<br>
> halting should also power down the system, unless it has chosen to<br>
> pass those calls on to hypervisor.<br>
<br>
Halt and poweroff are not the same thing.  If userspace requests a<br>
poweroff, then kernel_power_off() will call machine_power_off() which<br>
will call pm_power_off().<br>
<br>
Why do we need anything corenet-specific here?</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We don't, but then the board will halt instead of power off when you type shutdown -h now. Or if you type poweroff without a high enough run level, apparently. I'm amenable to removing the halt code, but there are concerns that this will cause the systems to behave unintentionally as intended, in that most systems that users interact with shut down when you call shutdown -h now. There may be scripts that depend on that behavior (or at least assume it). Perhaps I could add a config option? CONFIG_TREAT_HALT_AS_POWEROFF? CONFIG_POWEROFF_ON_HALT?</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'll note that there is one other board that is doing the same thing, but they've implemented their own gpio poweroff driver. See commit 5611fe48c545a22e62273428ed74c9bfae4a9406. That commit also points vaguely in the direction of an answer to your second question...</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> @@ -127,6 +137,12 @@ static const struct of_device_id of_device_ids[] = {<br>
>       {<br>
>               .name           = "handles",<br>
>       },<br>
> +     {<br>
> +             .name           = "gpio-poweroff",<br>
> +     },<br>
> +     {<br>
> +             .name           = "gpio-restart",<br>
> +     },<br>
>       {}<br>
>  };<br>
><br>
<br>
I don't see any other platforms doing this.  How do the nodes get probed<br>
for them?</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The answer is I don't know, but this is a common issue with adding new devices to the device tree in embedded powerpc. The only other platforms which have gpio-poweroff nodes in their trees are in arch/arm, and none of those platforms call the probing function of_platform_bus_probe. I suspect they either probe every root node, or they somehow construct the match_id. As noted in the above-referenced commit, putting the nodes under the gpio bus does not cause them to get probed. This seemed like the best way under the current corenet code.<br>
<br>
-Scott<br>
<br>
</blockquote>