Files
build/patch/kernel/archive/rockchip64-6.3/general-rk808-configurable-switch-voltage-steps.patch

185 lines
9.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Piotr Szczepanik <piter75@gmail.com>
Date: Tue, 2 Mar 2021 21:07:22 +0100
Subject: allows to change the way that BUCK1 and BUCK2 of rk808 PMIC
This patch allows to change the way that BUCK1 and BUCK2 of rk808 PMIC set voltage.
It allows to change the hardcoded max. 100mV per one change
to any multiple of 12.5mV while keeping the 100mV default.
It was observed that making the steps smaller (eg. 50mV = 4 * 12.5mV)
makes the NanoPi M4V2 running stable.
One can configure the max number of steps per single change using
the "max-buck-steps-per-change" property of rk808 node in device tree.
Below example ensures that voltage is not changed in jumps larger than 50mV:
&rk808 {
max-buck-steps-per-change = <4>;
}
Be aware that changing this parameter affects the time taken to switch between
OPPs of LiTTLE cores of rk3399.
For overclocked LiTTLE cores with base 408MHz @ 0.825V
and max. 1.5GHz @ 1.2V it will take 7 steps of 50mV (at least 65uS each - caused by i2c),
the final 25mV step and 1uS to settle: 7 x 65uS + 1uS = 456uS.
With default setting it would be 3 steps of 100mV (at least 65uS each - caused by i2c),
the final 75mV step and 1uS to settle: 3 x 65uS + 1uS = 196uS.
Signed-off-by: Piotr Szczepanik <piter75@gmail.com>
> X-Git-Archeology: > recovered message: > * Explicitly set vdd_log voltage for NanoPi M4V2 - possibly fix stability issues
> X-Git-Archeology: > recovered message: > * Regulator tweaks for NanoPi M4V2
> X-Git-Archeology: > recovered message: > * Add vdd_log to kernel and switch vdd_center back to 900mV
> X-Git-Archeology: > recovered message: > * Switch vdd_center to 0.95
> X-Git-Archeology: > recovered message: > * Make rk80x bucks voltage steps shorter to make the NanoPi M4V2 stable
> X-Git-Archeology: > recovered message: > * Tweak u-boot config for NanoPi M4V2
> X-Git-Archeology: > recovered message: > * Made the rk808 voltage steps configurable and configured 50mV for NanoPi M4V2
> X-Git-Archeology: - Revision a6ee913fae3afc7ae74bb1fdaf1f571ec30493ac: https://github.com/armbian/build/commit/a6ee913fae3afc7ae74bb1fdaf1f571ec30493ac
> X-Git-Archeology: Date: Tue, 02 Mar 2021 21:07:22 +0100
> X-Git-Archeology: From: Piotr Szczepanik <piter75@gmail.com>
> X-Git-Archeology: Subject: NanoPi M4V2 stability fix for current and dev (#2663)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 0cdffb29b07305209efb12cf3b5ac6032d3a1153: https://github.com/armbian/build/commit/0cdffb29b07305209efb12cf3b5ac6032d3a1153
> X-Git-Archeology: Date: Wed, 24 Mar 2021 19:01:53 +0100
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Renaming DEV branch to EDGE (#2704)
> X-Git-Archeology:
> X-Git-Archeology: - Revision e7377248b3cae186e24e2be781cd3365b43246f0: https://github.com/armbian/build/commit/e7377248b3cae186e24e2be781cd3365b43246f0
> X-Git-Archeology: Date: Thu, 22 Jul 2021 00:15:54 +0200
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Second part of EDGE bumping to 5.13.y (#3045)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 744ea89a589d62cb6f409baab60fc6664520bc39: https://github.com/armbian/build/commit/744ea89a589d62cb6f409baab60fc6664520bc39
> X-Git-Archeology: Date: Wed, 08 Sep 2021 17:51:34 +0200
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Bumping EDGE kernel to 5.14.y (#3125)
> X-Git-Archeology:
> X-Git-Archeology: - Revision dd51f9f2afcbc83a3e10b32eb6a5061d91d1558e: https://github.com/armbian/build/commit/dd51f9f2afcbc83a3e10b32eb6a5061d91d1558e
> X-Git-Archeology: Date: Tue, 09 Nov 2021 18:06:34 +0100
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Bump imx6, xu4, rockchip64 and jetson-nano to 5.15 (#3238)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 6b490e16944b30ff69bf9c13678905187df0d9d4: https://github.com/armbian/build/commit/6b490e16944b30ff69bf9c13678905187df0d9d4
> X-Git-Archeology: Date: Tue, 11 Jan 2022 15:26:11 +0100
> X-Git-Archeology: From: Oleg <balbes-150@yandex.ru>
> X-Git-Archeology: Subject: move kernel edge to 5.16 (#3387)
> X-Git-Archeology:
> X-Git-Archeology: - Revision ac8fc4385594d59257ee9dffd9efa85e3497fa7d: https://github.com/armbian/build/commit/ac8fc4385594d59257ee9dffd9efa85e3497fa7d
> X-Git-Archeology: Date: Sat, 26 Feb 2022 07:46:44 +0100
> X-Git-Archeology: From: Piotr Szczepanik <piter75@gmail.com>
> X-Git-Archeology: Subject: Switch rockchip64 current to linux 5.15.y (#3489)
> X-Git-Archeology:
> X-Git-Archeology: - Revision f52a4193d02ef88333ba117c68d49486dfd7ff41: https://github.com/armbian/build/commit/f52a4193d02ef88333ba117c68d49486dfd7ff41
> X-Git-Archeology: Date: Sun, 20 Mar 2022 22:58:21 +0100
> X-Git-Archeology: From: Oleg <balbes-150@yandex.ru>
> X-Git-Archeology: Subject: Adding Pine64 Quartz64a as WIP target (#3539)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 0afe24c95729044910e0b3f84dc5500bcdc6524c: https://github.com/armbian/build/commit/0afe24c95729044910e0b3f84dc5500bcdc6524c
> X-Git-Archeology: Date: Sun, 24 Apr 2022 22:33:47 +0200
> X-Git-Archeology: From: Oleg <balbes-150@yandex.ru>
> X-Git-Archeology: Subject: move kernel media edge to 5.17 (#3704)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 897674aa74bce0326ed7fe06f5336bf4709a8a1f: https://github.com/armbian/build/commit/897674aa74bce0326ed7fe06f5336bf4709a8a1f
> X-Git-Archeology: Date: Tue, 03 May 2022 08:27:32 +0200
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Bump and freeze kernel at last known working versions (#3736)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 597d2dac11f00d9070a4e49d6bad1b2244e36cb3: https://github.com/armbian/build/commit/597d2dac11f00d9070a4e49d6bad1b2244e36cb3
> X-Git-Archeology: Date: Sat, 28 May 2022 07:56:22 +0200
> X-Git-Archeology: From: Jianfeng Liu <liujianfeng1994@gmail.com>
> X-Git-Archeology: Subject: update rockchip64-edge to 5.18 (#3814)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 8c6641e7b79f0d50acdc306d140e586a4e923cf0: https://github.com/armbian/build/commit/8c6641e7b79f0d50acdc306d140e586a4e923cf0
> X-Git-Archeology: Date: Wed, 03 Aug 2022 22:22:55 +0200
> X-Git-Archeology: From: Jianfeng Liu <liujianfeng1994@gmail.com>
> X-Git-Archeology: Subject: update rockchip64 edge to 5.19 (#4039)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 6765f734cc4a22aeaa9f99a3ad28c8c322de26f6: https://github.com/armbian/build/commit/6765f734cc4a22aeaa9f99a3ad28c8c322de26f6
> X-Git-Archeology: Date: Tue, 25 Oct 2022 11:26:51 +0200
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Bump rockchip64 edge to 6.0.y (#4337)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 92f1a22d76b987afa7ba555d5b509adc51d689e7: https://github.com/armbian/build/commit/92f1a22d76b987afa7ba555d5b509adc51d689e7
> X-Git-Archeology: Date: Fri, 16 Dec 2022 13:38:13 +0100
> X-Git-Archeology: From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology: Subject: Re-add rockchip64 6.0 patches (#4575)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 34ae84fac5d0b66a1ab2d1e51534b7beb13ef245: https://github.com/armbian/build/commit/34ae84fac5d0b66a1ab2d1e51534b7beb13ef245
> X-Git-Archeology: Date: Fri, 05 May 2023 14:22:00 +0200
> X-Git-Archeology: From: amazingfate <liujianfeng1994@gmail.com>
> X-Git-Archeology: Subject: bump rockchip64 edge to v6.3
> X-Git-Archeology:
---
drivers/regulator/rk808-regulator.c | 17 +++++++---
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index fa9fc1aa1ae3..94f359b88dea 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -155,6 +155,7 @@
struct rk808_regulator_data {
struct gpio_desc *dvs_gpio[2];
+ unsigned max_buck_steps_per_change;
};
static const struct linear_range rk808_ldo3_voltage_ranges[] = {
@@ -240,7 +241,8 @@ static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev)
}
static int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev *rdev,
- unsigned sel)
+ unsigned sel,
+ int max_steps)
{
int ret, delta_sel;
unsigned int old_sel, tmp, val, mask = rdev->desc->vsel_mask;
@@ -259,8 +261,8 @@ static int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev *rdev,
* the risk of overshoot. Put it into a multi-step, can effectively
* avoid this problem, a step is 100mv here.
*/
- while (delta_sel > MAX_STEPS_ONE_TIME) {
- old_sel += MAX_STEPS_ONE_TIME;
+ while (delta_sel > max_steps) {
+ old_sel += max_steps;
val = old_sel << (ffs(mask) - 1);
val |= tmp;
@@ -294,12 +296,13 @@ static int rk808_buck1_2_set_voltage_sel(struct regulator_dev *rdev,
struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
struct gpio_desc *gpio = pdata->dvs_gpio[id];
+ int max_steps = pdata->max_buck_steps_per_change;
unsigned int reg = rdev->desc->vsel_reg;
unsigned old_sel;
int ret, gpio_level;
if (!gpio)
- return rk808_buck1_2_i2c_set_voltage_sel(rdev, sel);
+ return rk808_buck1_2_i2c_set_voltage_sel(rdev, sel, max_steps);
gpio_level = gpiod_get_value(gpio);
if (gpio_level == 0) {
@@ -1277,6 +1280,12 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
0 : tmp);
}
+ tmp = of_property_read_u32(client_dev->of_node, "max-buck-steps-per-change", &pdata->max_buck_steps_per_change);
+ if (tmp) {
+ pdata->max_buck_steps_per_change = MAX_STEPS_ONE_TIME;
+ }
+ dev_info(dev, "max buck steps per change: %d\n", pdata->max_buck_steps_per_change);
+
dt_parse_end:
of_node_put(np);
return ret;
--
Armbian