From 08f5f62893ac4e7ac41df8ce667ff6b2b26adb0a Mon Sep 17 00:00:00 2001 From: Dongjin Kim Date: Thu, 27 Mar 2025 18:00:39 +0900 Subject: [PATCH] ODROID-M1: mfd/rk808: add _voltage_threadhold Add new property to set system low voltage and shutdown voltage to the register SYS_CFG0. &rk809 { ... low_voltage_threshold = <2800>; shutdown_voltage_threshold = <2700>; ... } Signed-off-by: Dongjin Kim Change-Id: I9c1a850485e93af9ea977ad35a70656e09a449a0 --- drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index 720b167018e0..8fa4b58c4063 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -1067,6 +1067,8 @@ 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; + int low_voltage_threshold; + int shutdown_voltage_threshold; ret = of_property_read_u32_index(np, "fb-inner-reg-idxs", 0, &inner); if (!ret && inner == RK817_ID_DCDC3) @@ -1101,6 +1103,43 @@ 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, + "low_voltage_threshold", &low_voltage_threshold); + if (ret < 0) { + low_voltage_threshold = 0; + dev_info(dev, "low_voltage_threshold missing!\n"); + } else { + if ((low_voltage_threshold > 3500) || + (low_voltage_threshold < 2800)) { + dev_err(dev, "low_voltage_threshold out [2800 3500]!\n"); + low_voltage_threshold = 2800; + } + } + + if (low_voltage_threshold) { + regmap_update_bits(rk808->regmap, RK817_SYS_CFG(0), BIT(3), BIT(3)); + regmap_update_bits(rk808->regmap, RK817_SYS_CFG(0), 0x07, + (low_voltage_threshold - 2800) / 100); + } + + ret = device_property_read_u32(dev, + "shutdown_voltage_threshold", &shutdown_voltage_threshold); + if (ret < 0) { + shutdown_voltage_threshold = 0; + dev_info(dev, "shutdown_voltage_threshold missing!\n"); + } + + if ((shutdown_voltage_threshold > 3400) || + (shutdown_voltage_threshold < 2700)) { + dev_err(dev, "shutdown_voltage_threshold out [2700 3400]!\n"); + shutdown_voltage_threshold = 2700; + } + + if (shutdown_voltage_threshold) { + regmap_update_bits(rk808->regmap, RK817_SYS_CFG(0), 0x7 << 4, + ((shutdown_voltage_threshold - 2700) / 100) << 4); + } } static struct kobject *rk8xx_kobj;