rk3568 电源键强制关机触发时间修改
Rockchip系列主控芯片配套PMIC支持长按电源键强制关闭PMU,也就是标题中的强制关机。rk3568使用I2C通信与PMIC(rk809/rk817),power(电源)键则是与PMIC相连,PMIC监测按键状态控制RK3568的上下电,实现短按开机、长按强制断电关机。电源键触发rk809/rk817开启供电时间同样可有相关寄存器调整。
作者:炭烤毛蛋 ,点击博主了解更多。
提示:PMU多个工作状态寄存器,可修改相关参数实现调整强制关机时间,开机触发时间。
文章目录
- rk3568 电源键强制关机触发时间修改
- 1. 核查硬件,适配硬件强制关机
- 1.1 PMIC(rk809、rk817) 电源键设备树注册
- 1.2 PMIC(rk809、rk817) 电源键强制关机触发时间修改
- 1.3 PMIC(rk809、rk817) 屏蔽电源键强制关机
- Tips
- 总结
1. 核查硬件,适配硬件强制关机
RK809、RK817 电源键是直接与 PWRON(pin) 连接,电源键被按下时与GND导通,PWRON 信号被拉低;PMIC检测到该信号变化后触发相关操作。
1.1 PMIC(rk809、rk817) 电源键设备树注册
RK809、RK817 的电源键需要在 PMIC驱动中增加相关设备树描述。
&i2c0 {
status = "okay";
rk809: pmic@20 {
pwrkey {
status = "okay";
};
};
};
1.2 PMIC(rk809、rk817) 电源键强制关机触发时间修改
--- a/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
@@ -1141,6 +1141,10 @@
/* not save the PMIC_POWER_EN register in uboot */
not-save-power-en = <1>;
+ /* PWRON_LP_OFF_TIME: PWRON long press time:
+ * 6s, 8s, 10s, 12s */
+ pwron-lp-off-time = <10>;
+
vcc1-supply = <&vcc3v3_sys>;
vcc2-supply = <&vcc3v3_sys>;
vcc3-supply = <&vcc3v3_sys>;
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8c207a2899d4..f6befe99eb33 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -1126,6 +1126,7 @@ static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
u32 inner;
int ret, func, msk, val;
struct device_node *np = dev->of_node;
+ uint32_t value;
ret = of_property_read_u32_index(np, "fb-inner-reg-idxs", 0, &inner);
if (!ret && inner == RK817_ID_DCDC3)
@@ -1160,6 +1161,25 @@ static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
ret = register_reboot_notifier(&rk817_reboot_data.reboot_notifier);
if (ret)
dev_err(dev, "failed to register reboot nb\n");
+
+ 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 <= 6)
+ val = RK817_PWRON_LP_OFF_TIME_6S;
+ else if (value <= 8)
+ val = RK817_PWRON_LP_OFF_TIME_8S;
+ else if (value <= 10)
+ val = RK817_PWRON_LP_OFF_TIME_10S;
+ else
+ val = RK817_PWRON_LP_OFF_TIME_12S;
+ regmap_update_bits(rk808->regmap, RK817_PMIC_PWRON_KEY,
+ RK817_PMIC_PWRON_KEY_MSK,
+ val);
+ }
}
static struct kobject *rk8xx_kobj;
1.3 PMIC(rk809、rk817) 屏蔽电源键强制关机
diff --git a/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi b/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
index 1bfaeb681069..7183b00904dc 100644
--- a/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
@@ -1141,6 +1141,11 @@
/* not save the PMIC_POWER_EN register in uboot */
not-save-power-en = <1>;
+ /* PWRON_LP_OFF_TIME: PWRON long press time:
+ * 6s, 8s, 10s, 12s */
+ pwron-lp-off-time = <12>;
+ pwron_lp_act = <0>;
+
vcc1-supply = <&vcc3v3_sys>;
vcc2-supply = <&vcc3v3_sys>;
vcc3-supply = <&vcc3v3_sys>;
diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 8c207a2899d4..844adc944a0a 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -1126,6 +1126,7 @@ static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
u32 inner;
int ret, func, msk, val;
struct device_node *np = dev->of_node;
+ uint32_t value;
ret = of_property_read_u32_index(np, "fb-inner-reg-idxs", 0, &inner);
if (!ret && inner == RK817_ID_DCDC3)
@@ -1160,6 +1161,41 @@ static void rk817_of_property_prepare(struct rk808 *rk808, struct device *dev)
ret = register_reboot_notifier(&rk817_reboot_data.reboot_notifier);
if (ret)
dev_err(dev, "failed to register reboot nb\n");
+
+ ret = device_property_read_u32(dev,
+ "pwron_lp_act",
+ &value);
+ if (ret < 0) {
+ dev_info(dev, "pwron-lp-off-time missing!\n");
+ } else {
+ if (value)
+ regmap_update_bits(rk808->regmap, RK817_PMIC_PWRON_KEY,
+ RK817_PWRON_LP_ACT_MSK,
+ RK817_PWRON_LP_ACT_ON);
+ else
+ regmap_update_bits(rk808->regmap, RK817_PMIC_PWRON_KEY,
+ RK817_PWRON_LP_ACT_MSK,
+ RK817_PWRON_LP_ACT_OFF);
+ }
+
+ 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 <= 6)
+ val = RK817_PWRON_LP_OFF_TIME_6S;
+ else if (value <= 8)
+ val = RK817_PWRON_LP_OFF_TIME_8S;
+ else if (value <= 10)
+ val = RK817_PWRON_LP_OFF_TIME_10S;
+ else
+ val = RK817_PWRON_LP_OFF_TIME_12S;
+ regmap_update_bits(rk808->regmap, RK817_PMIC_PWRON_KEY,
+ RK817_PMIC_PWRON_KEY_MSK,
+ val);
+ }
}
static struct kobject *rk8xx_kobj;
Tips
- 确认rk809、rk817寄存器是否正常设置,可以使用 i2cdump命令回读数据。
- 验证寄存器是否有效,可使用命令 i2c_set 手动设置寄存器取值,然后验证设置效果。
总结
不枉博主详细讲解,欢迎订阅博主–炭烤毛蛋 。