RK3588长按power键强制关机的按键时间设置

RK3588长按power键强制关机的按键时间设置

本文适用于RK3588+RK806(电源管理芯片)的方案,power(电源)键是直接控制RK806来控制RK3588的上下电,可以实现短按开机、长按强制断电关机的功能,可以通过控制RK806的寄存器来设置长按的时间长短。

RK3588按power键强制关机的按键时间设置

RK806的power键长按时间可以配置为如下几个值:

  • 00: 6000ms,
  • 01: 8000ms,
  • 10: 10000ms,
  • 11: 12000ms
    下面以配置12秒为例进行说明,其中PMIC是单pmic的方案,如果是双pmic的话需要修改rk3588-rk806-dual.dtsi
:~/a2_Android13_29_sdk/kernel-5.10$ git diff
diff --git a/arch/arm64/boot/dts/rockchip/rk3588-rk806-single.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-rk806-single.dtsi
index 62f3403789b7..48e28aa0c85f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3588-rk806-single.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3588-rk806-single.dtsi
@@ -44,6 +44,10 @@
                 */
                pmic-reset-func = <1>;

+               /* PWRON_LP_OFF_TIME: PWRON long press time:
+               * 00: 6000ms, 01: 8000ms, 10: 10000ms, 11: 12000ms */
+               pwron-lp-off-time = <12000>;
+
                vcc1-supply = <&vcc5v0_sys>;
                vcc2-supply = <&vcc5v0_sys>;
                vcc3-supply = <&vcc5v0_sys>;
diff --git a/drivers/mfd/rk806-core.c b/drivers/mfd/rk806-core.c
index 5421ac95578f..2fbc2e967fef 100644
--- a/drivers/mfd/rk806-core.c
+++ b/drivers/mfd/rk806-core.c
@@ -620,6 +620,7 @@ static int rk806_parse_dt(struct rk806 *rk806)
        struct device *dev = rk806->dev;
        int rst_fun;
        int ret;
+       int value;

        pdata = rk806->pdata;

@@ -678,6 +679,25 @@ static int rk806_parse_dt(struct rk806 *rk806)
        if (device_property_read_bool(dev, "pwron-on-time-500ms"))
                rk806_field_write(rk806, PWRON_ON_TIME, 0x00);

+       if (device_property_read_bool(dev, "pwron-lp-to-reset"))
+               rk806_field_write(rk806, PWRON_LP_ACT, 0x01);
+
+       ret = device_property_read_u32(dev,
+               "pwron-lp-off-time",
+               &value);
+       if (ret < 0) {
+               dev_info(dev, "pwron-lp-off-time missing!\n");
+       } else {
+               if (value <= 6000)
+                       rk806_field_write(rk806, PWRON_LP_OFF_TIME, 0x00);
+               else if (value <= 8000)
+                       rk806_field_write(rk806, PWRON_LP_OFF_TIME, 0x01);
+               else if (value <= 10000)
+                       rk806_field_write(rk806, PWRON_LP_OFF_TIME, 0x02);
+               else
+                       rk806_field_write(rk806, PWRON_LP_OFF_TIME, 0x03);
+       }
+
        return 0;
 }

你可能感兴趣的:(RK3588,rk806,RK3588,电源键,长按关机,rk806寄存器)