Giter Site home page Giter Site logo

Shutdown/restart support about linux HOT 13 CLOSED

PabloPL avatar PabloPL commented on June 30, 2024
Shutdown/restart support

from linux.

Comments (13)

xc-racer99 avatar xc-racer99 commented on June 30, 2024

I was thinking something like

diff --git a/arch/arm/boot/dts/s5pv210-aries.dtsi b/arch/arm/boot/dts/s5pv210-aries.dtsi
index 1a8ccd86c893..213d5baf2b90 100644
--- a/arch/arm/boot/dts/s5pv210-aries.dtsi
+++ b/arch/arm/boot/dts/s5pv210-aries.dtsi
@@ -415,3 +415,25 @@
 &pwm {
        samsung,pwm-outputs = <1>;
 };
+
+&pmu_syscon {
+       compatible = "samsung-s5pv210-pmu", "simple-mfd", "syscon";
+
+       /* Write magic to INFORM5 to prevent charger on reboot */
+       reboot-mode {
+               compatible = "syscon-reboot-mode";
+               offset = <0x7014 /* INFORM5 */>;
+               mode-normal = <0x12345678>;
+               mode-recovery = <0x12345678>;
+               mode-bootloader = <0x12345678>;
+       };
+
+       /* Writes actual reboot code to INFORM6 */
+       reboot-mode {
+               compatible = "syscon-reboot-mode";
+               offset = <0x7018 /* INFORM6 */>;
+               mode-normal = <0x0>;
+               mode-recovery = <0x2>;
+               mode-bootloader = <0x4>;
+       };
+};

for the reboot mode notifier (don't know if you can stack up the reboot modes or not... this is totally untested)

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

Rebooting functions by using xc-racer99@e94d34c

Still struggling with syscon-reboot-mode and syscon-poweroff to get parameters written to the INFORM registers/regular shutdown

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

xc-racer99@b245a36 is functional for syscon poweroff support. Needs the following added to the defconfig

CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_SYSCON_POWEROFF=y

I cannot seem to get syscon-reboot-mode to even probe, so I can't test if my code above works (yes, I have modified the defconfig for it)

from linux.

PabloPL avatar PabloPL commented on June 30, 2024

About syscon poweroff, i've applied it to for-upstream/aries-patches-v2 branch and when invoking shutdown, device is still showing logs on screen (last entry is "reboot: System halted").
Shouldn't power be turned off?

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

Umm, what command are you using to shutdown? Running "shutdown now" on Debian gives the following

[  OK  ] Reached target Shutdown.
systemd-shutdow: 19 output lines suppressed due to ratelimiting
systemd-shutdown[1]: Sending SIGTERM to remaining processes...
systemd-journald[1179]: Received SIGTERM from PID 1 (systemd-shutdow).
systemd-shutdown[1]: Sending SIGKILL to remaining processes...
systemd-shutdown[1]: Unmounting file systems.
systemd-shutdown[1]: Remounting '/' read-only with options ''.
EXT4-fs (mmcblk1p1): re-mounted. Opts: 
systemd-shutdown[1]: Remounting '/' read-only with options ''.
EXT4-fs (mmcblk1p1): re-mounted. Opts: 
systemd-shutdown[1]: All filesystems unmounted.
systemd-shutdown[1]: Deactivating swaps.
systemd-shutdown[1]: All swaps deactivated.
systemd-shutdown[1]: Detaching loop devices.
systemd-shutdown[1]: All loop devices detached.
rebo

when building from the for-upstream/aries-patches-v2 branch

from linux.

PabloPL avatar PabloPL commented on June 30, 2024

By just running shutdown. I can see in log message that board is halted, but screen is still working.

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

Weird. Does just pushing the power button turn it on again?

Vendor kernel read from PS_HOLD_CONTROL and then writes it back, see https://github.com/xc-racer99/android_kernel_samsung_aries/blob/aosp-7.1/arch/arm/mach-s5pv210/mach-aries.c#L4326

For my variant, reading from PS_HOLD_CONTROL gave a value of 0x5301, but I used 0x5200 as that is what is in arch/arm/boot/dts/exynos-syscon-restart.dtsi - using the value of 0x5301 didn't work as the syscon driver won't write something to the register if it's already there.

You can play around with different values in u-boot using the command

mw.b 0xe010e81c 0x5301 1

from linux.

PabloPL avatar PabloPL commented on June 30, 2024

Without cable attached it's working fine (device/screen is powered off and booted by pressing button again after shutdown. Maybe it's related to unbrickable mod?
Sorry for problems.

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

syscon poweroff was merged as part of Aries v2 patches; we still need to figure out why the S5P_SW_RESET doesn't work or else make adjusts to the watchdog driver so we can use it to reset as in the vendor kernel (and ported upstream in xc-racer99@e94d34c)

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

It should be noted that when using the SD card SPL in u-boot, then S5P_SW_RESET works as one would expect.

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

I think we can close this, the reason that the SW_RESET doesn't work is due to a mistake in the stock bootloader. For some reason it assumes that the memory will already be setup, while in fact it isn't.

from linux.

PabloPL avatar PabloPL commented on June 30, 2024

No dts changes needed? Till now only poweroff was merged.

from linux.

xc-racer99 avatar xc-racer99 commented on June 30, 2024

Yep, no DTS changes needed, it works as expected when using the WIP SPL branch of u-boot.

The SW_RESET hook is hard-coded in the s5pv210 common support at https://github.com/PabloPL/linux/blob/master/arch/arm/mach-s5pv210/s5pv210.c#L71

I suppose we could set the reboot-mode entries for configuring the bootloader, but there's no standard about this. We could either match the stock bootloader or else the midas config.

from linux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.