RK3399 GMAC 高速时候不稳定解决笔记

/ 0评 / 1

硬件是一个没有原理图的电视盒,有网口,大致移植后出现网口不稳定,表现为大流量自动断网.

提高vdd_log能临时解决.

echo 1050000 > /sys/kernel/debug/regulator/vdd_log/voltage

用户空间解决办法可以这样,但是并不优雅,打算改一下.

	vdd_log: vdd-log {
		compatible = "pwm-regulator";
		pwms = <&pwm2 0 25000 1>;
		regulator-name = "vdd_log";
		/*
		 * the firefly hardware using 3.0 v as APIO2_VDD
		 * voltage, but the pwm divider resistance is designed
		 * based on hardware which the APIO2_VDD is 1.8v.
		 * The correct min-microvolt measure in hardware is 430mV
		 * and the max-microvolt is 1.4V.
		 */
		regulator-min-microvolt = <800000>;
		regulator-max-microvolt = <1400000>;
		/* 加入0.3V偏置,这样电压就能达标. */
		regulator-microvolt-offset = <300000>;
		regulator-always-on;
		regulator-boot-on;
		/* 加入电源树防止警告 */
		pwm-supply = <&vcc5v0_sys>;
	};

我使用的是RK维护内核,毕竟只有这个功能才比较齐全,比较老,不能设置初始电压,设置偏置一样的.比较优雅的方法,自己做一个初始化电压的方法.

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 389dadd89fda..e1de6d795b3d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -924,6 +924,20 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
                }
        }
 
+       if (rdev->constraints->init_uV) {
+               ret = _regulator_do_set_voltage(rdev,
+                                               rdev->constraints->init_uV,
+                                               rdev->constraints->init_uV);
+               if (ret < 0) {
+                       rdev_err(rdev, "failed to set init %duV constraint\n",
+                                rdev->constraints->init_uV);
+                       return ret;
+               }
+
+               rdev_info(rdev, "applied init %duV constraint\n",
+                                rdev->constraints->init_uV);
+       }
+
        /* constrain machine-level voltage specs to fit
         * the actual range supported by this regulator.
         */
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 9067049fa336..5643065fd474 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -42,6 +42,9 @@ static void of_get_regulation_constraints(struct device_node *np,
        if (!of_property_read_u32(np, "regulator-max-microvolt", &pval))
                constraints->max_uV = pval;
 
+       if (!of_property_read_u32(np, "regulator-init-microvolt", &pval))
+               constraints->init_uV = pval;
+
        if (!of_property_read_u32(np, "regulator-earl
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 07e913c791aa..3914f272d5a0 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -128,6 +128,7 @@ struct regulation_constraints {
        /* voltage output range (inclusive) - for voltage control */
        int min_uV;
        int max_uV;
+       int init_uV;
 
        /* Minimum voltage during system startup */
        int early_min_uV;
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dts b/arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dts
index 8dd950e4903a..7eee0b4a1209 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-firefly-linux.dts
@@ -190,7 +190,8 @@
                regulator-min-microvolt = <800000>;
                regulator-max-microvolt = <1400000>;
+               regulator-init-microvolt = <1050000>;
                regulator-always-on;
                regulator-boot-on;
                /* 加入电源树 */

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注