linux 内核regulator

问题

  在sys文件系统下没有生成cpu 调频的相关节点。

日志对比

[    3.588745] cpu cpu4: Looking up cpu-supply from device tree
[    3.588753] cpu cpu4: Failed to get reg
[    3.588791] cpu cpu4: Looking up cpu-supply from device tree
[    3.588808] Failed to initialize dvfs info cpu4

代码流程

  cpufreq

kernel\drivers\soc\rockchip\rockchip_opp_select.c

static int rockchip_get_pvtm_pvtpll(struct device *dev, struct device_node *np,
				    char *reg_name)
{
	struct regulator *reg;
	struct clk *clk;
	struct pvtm_config *pvtm;
	unsigned long old_freq;
	unsigned int old_volt;
	int cur_temp, diff_temp, prop_temp, diff_value;
	int pvtm_value = 0;
	int ret = 0;

	pvtm = kzalloc(sizeof(*pvtm), GFP_KERNEL);
	if (!pvtm)
		return -ENOMEM;

	ret = rockchip_parse_pvtm_config(np, pvtm);
	if (ret)
		goto out;

	clk = clk_get(dev, NULL);
	if (IS_ERR_OR_NULL(clk)) {
		dev_warn(dev, "Failed to get clk\n");
		goto out;
	}
    //如下这行打印出的失败信息
	reg = regulator_get_optional(dev, reg_name);
	if (IS_ERR_OR_NULL(reg)) {
		dev_warn(dev, "Failed to get reg\n");
		clk_put(clk);
		goto out;
	}

I:\rk3588\kernel\drivers\cpufreq\rockchip-cpufreq.c

static int rockchip_cpufreq_cluster_init(int cpu, struct cluster_info *cluster)
{
	struct rockchip_opp_info *opp_info = &cluster->opp_info;
	struct opp_table *pname_table = NULL;
	struct opp_table *reg_table = NULL;

   if (opp_info->data && opp_info->data->get_soc_info)
		opp_info->data->get_soc_info(dev, np, &bin, &process);
	rockchip_get_scale_volt_sel(dev, "cpu_leakage", reg_name, bin, process,
				    &cluster->scale, &volt_sel); //入口函数
static int __init rockchip_cpufreq_driver_init(void)
{
	struct cluster_info *cluster, *pos;
	struct cpufreq_dt_platform_data pdata = {0};
	int cpu, ret;

	for_each_possible_cpu(cpu) {
		cluster = rockchip_cluster_info_lookup(cpu);
		if (cluster)
			continue;

		cluster = kzalloc(sizeof(*cluster), GFP_KERNEL);
		if (!cluster) {
			ret = -ENOMEM;
			goto release_cluster_info;
		}

		ret = rockchip_cpufreq_cluster_init(cpu, cluster);
		if (ret) {
			pr_err("Failed to initialize dvfs info cpu%d\n", cpu);
			goto release_cluster_info;
		}
		list_add(&cluster->list_head, &cluster_info_list);
	}

regulator

_regulator_get

I:\rk3588\kernel\drivers\regulator\core.c

根据此函数,猜测由于regulator设备没有被发现,没有被注册到系统中,导致cpufreq没有找到相应的regulator节点。

rk806

I:\rk3588\kernel\drivers\regulator\rk806-regulator.c

rk860

I:\rk3588\kernel\drivers\regulator\rk860x-regulator.c

DTS配置
&i2c0 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c0m2_xfer>;

	vdd_cpu_big0_s0: vdd_cpu_big0_mem_s0: rk8602@42 {
		compatible = "rockchip,rk8602";
		reg = <0x42>;
		vin-supply = <&vcc5v0_sys>;
		vsel-gpios = <&gpio0 RK_PA3 GPIO_ACTIVE_HIGH>;
		regulator-compatible = "rk860x-reg";
		regulator-name = "vdd_cpu_big0_s0";
		regulator-min-microvolt = <550000>;
		regulator-max-microvolt = <1050000>;
		regulator-ramp-delay = <2300>;
		rockchip,suspend-voltage-selector = <1>;
		regulator-boot-on;
		regulator-always-on;
		regulator-state-mem {
			regulator-off-in-suspend;
		};
	};
sys节点创建

rk860x_regulator_register--》devm_regulator_register->regulator_register

-->rdev_init_debugfs-->

此处没有创建设备节点,也就是前面初始化部分出现问题了。

初始化代码

/* Get chip ID */
	ret = regmap_read(di->regmap, RK860X_ID1, &val);
	if (ret < 0) {
		dev_err(&client->dev, "Failed to get chip ID!\n");
		return ret;
	}

	switch (di->chip_id) {
	case RK860X_CHIP_ID_00:
	case RK860X_CHIP_ID_01:
		if ((val & DIE_ID) != 0x8) {
			dev_err(&client->dev, "Failed to match chip ID!\n");
			return -EINVAL;
		}
		break;
	case RK860X_CHIP_ID_02:
	case RK860X_CHIP_ID_03:
		if ((val & DIE_ID) != 0xa) {
			dev_err(&client->dev, "Failed to match chip ID!\n");
			return -EINVAL;
		}
		break;
	default:
		return -EINVAL;
	}

	/* Device init */
	ret = rk860x_device_setup(di, pdata);
	if (ret < 0) {
		dev_err(&client->dev, "Failed to setup device!\n");
		return ret;
	}
	/* Register regulator */
	config.dev = di->dev;
	config.init_data = di->regulator;
	config.regmap = di->regmap;
	config.driver_data = di;
	config.of_node = np;

	ret = rk860x_regulator_register(di, &config);
	if (ret < 0)
		dev_err(&client->dev, "Failed to register regulator!\n");
回看dmesg日志
[    3.509295] i2c /dev entries driver
[    3.510437] rk860-regulator 0-0042: Failed to match chip ID!
[    3.510478] rk860-regulator: probe of 0-0042 failed with error -22
[    3.511089] rk860-regulator 0-0043: Failed to match chip ID!
[    3.511120] rk860-regulator: probe of 0-0043 failed with error -22
[    3.514659] rk860-regulator 1-0042: Looking up vin-supply from device tree

对比正常日志

也就是从I2C读取的ID 信息不对。

读取偏移量为0x3

sys文件系统调试信息

regulator summary

查看只有 vdd_cpu_lit_s0   没有两个大核的信息,可以确认两个大核对应的regulator没有生成

cat /sys/kernel/debug/regulator/regulator_summary
 regulator                      use open bypass  opmode voltage current     min     max
---------------------------------------------------------------------------------------
 regulator-dummy                  4    4      0 unknown     0mV     0mA     0mV     0mV
    fe210000.sata-target          1                                 0mA     0mV     0mV
    fe210000.sata-phy             1                                 0mA     0mV     0mV
    fe210000.sata-ahci            1                                 0mA     0mV     0mV
    regulator-dummy               0                                 0mA     0mV     0mV
 vcc12v_dcin                      3    3      0 unknown 12000mV     0mA 12000mV 12000mV
    vcc12v_dcin                   0                                 0mA     0mV     0mV
    vcc5v0_sys                   16   16      0 unknown  5000mV     0mA  5000mV  5000mV
       vcc5v0_sys                 0                                 0mA     0mV     0mV
       vcc_1v1_nldo_s3            6    6      0 unknown  1100mV     0mA  1100mV  1100mV
          vcc_1v1_nldo_s3         0                                 0mA     0mV     0mV
          vdd_0v75_s3             1    1      0 unknown   750mV     0mA   750mV   750mV
             vdd_0v75_s3          0                                 0mA     0mV     0mV
          vdd_ddr_pll_s0          1    1      0 unknown   850mV     0mA   850mV   850mV
             vdd_ddr_pll_s0       0                                 0mA     0mV     0mV
          avdd_0v75_s0            2    2      0 unknown   750mV     0mA   750mV   750mV
             avdd_0v75_s0         0                                 0mA     0mV     0mV
             pcie30_avdd0v75      1    1      0 unknown   750mV     0mA   750mV   750mV
                pcie30_avdd0v75   0                                 0mA     0mV     0mV
          vdd_0v85_s0             2    2      0 unknown   850mV     0mA   850mV   850mV
             vdd_0v85_s0          0                                 0mA     0mV     0mV
             pcie20_avdd0v85      1    1      0 unknown   850mV     0mA   850mV   850mV
                pcie20_avdd0v85   0                                 0mA     0mV     0mV
          vdd_0v75_s0             1    1      0 unknown   750mV     0mA   750mV   750mV
             vdd_0v75_s0          0                                 0mA     0mV     0mV
       vdd_gpu_s0                 0    5      0  normal   675mV     0mA   550mV   950mV
          fb000000.gpu-mem        0                                 0mA   675mV   950mV
          fb000000.gpu-mali       0                                 0mA   675mV   950mV
          fb000000.gpu-mem        0                                 0mA     0mV     0mV
          fb000000.gpu-mali       0                                 0mA     0mV     0mV
          vdd_gpu_s0              0                                 0mA     0mV     0mV
       vdd_cpu_lit_s0             1    3      0  normal   750mV     0mA   550mV   950mV
          cpu0-mem                0                                 0mA     0mV     0mV
          cpu0-cpu                0                                 0mA     0mV     0mV
          vdd_cpu_lit_s0          0                                 0mA     0mV     0mV
       vdd_log_s0                 1    1      0  normal   750mV     0mA   675mV   750mV
          vdd_log_s0              0                                 0mA     0mV     0mV
       vdd_vdenc_s0               1    1      0  normal   750mV     0mA   550mV   950mV
          vdd_vdenc_s0            0                                 0mA     0mV     0mV
       vdd_ddr_s0                 1    1      0  normal   850mV     0mA   675mV   900mV
          vdd_ddr_s0              0                                 0mA     0mV     0mV
       vdd2_ddr_s3                1    1      0  normal   500mV     0mA     0mV     0mV
          vdd2_ddr_s3             0                                 0mA     0mV     0mV
       vdd_2v0_pldo_s3            4    4      0  normal  2000mV     0mA  2000mV  2000mV
          vdd_2v0_pldo_s3         0                                 0mA     0mV     0mV
          avcc_1v8_s0             3    3      0 unknown  1800mV     0mA  1800mV  1800mV
             avcc_1v8_s0          0                                 0mA     0mV     0mV
             pcie30_avdd1v8       1    1      0 unknown  1800mV     0mA  1800mV  1800mV
                pcie30_avdd1v8    0                                 0mA     0mV     0mV
             pcie20_avdd1v8       1    1      0 unknown  1800mV     0mA  1800mV  1800mV
                pcie20_avdd1v8    0                                 0mA     0mV     0mV
          vcc_1v8_s0              2    2      0 unknown  1800mV     0mA  1800mV  1800mV
             fec10000.saradc-vref   1                                 0mA     0mV     0mV
             vcc_1v8_s0           0                                 0mA     0mV     0mV
          avdd_1v2_s0             1    1      0 unknown  1200mV     0mA  1200mV  1200mV
             avdd_1v2_s0          0                                 0mA     0mV     0mV
       vcc_3v3_s3                 1    1      0  normal  3300mV     0mA  3300mV  3300mV
          vcc_3v3_s3              0                                 0mA     0mV     0mV
       vddq_ddr_s0                1    1      0  normal   500mV     0mA     0mV     0mV
          vddq_ddr_s0             0                                 0mA     0mV     0mV
       vcc_1v8_s3                 1    1      0  normal  1800mV     0mA  1800mV  1800mV
          vcc_1v8_s3              0                                 0mA     0mV     0mV
       vcc_3v3_s0                 1    1      0 unknown  3300mV     0mA  3300mV  3300mV
          vcc_3v3_s0              0                                 0mA     0mV     0mV
       vccio_sd_s0                1    1      0 unknown  3300mV     0mA  1800mV  3300mV
          vccio_sd_s0             0                                 0mA     0mV     0mV
       pldo6_s3                   1    1      0 unknown  1800mV     0mA  1800mV  1800mV
          pldo6_s3                0                                 0mA     0mV     0mV
       vdd_npu_s0                 1    5      0  normal   825mV     0mA   550mV   950mV
          fdab0000.npu-mem        0                                 0mA   825mV   950mV
          fdab0000.npu-rknpu      0                                 0mA   825mV   950mV
          fdab0000.npu-mem        0                                 0mA     0mV     0mV
          fdab0000.npu-rknpu      0                                 0mA     0mV     0mV
          vdd_npu_s0              0                                 0mA     0mV     0mV
    vcc5v0_usbdcin                2    2      0 unknown  5000mV     0mA  5000mV  5000mV
       vcc5v0_usbdcin             0                                 0mA     0mV     0mV
       vcc5v0_usb                 1    2      0 unknown  5000mV     0mA  5000mV  5000mV
          vcc5v0_usb              0                                 0mA     0mV     0mV
          vbus5v0_typec           0    2      0 unknown  5000mV     0mA  5000mV  5000mV
             6-0022-vbus          0                                 0mA     0mV     0mV
             vbus5v0_typec        0                                 0mA     0mV     0mV

总结

        至此,我们找到了sys  cpufreq没有生成的根因。由于I2C的问题,导致regulator未生成,进而导致cpufreq在初始化时,查找对应的regulator失败。导致cpufreq相关节点没有生成。

linux 内核regulator_第1张图片

   进一步的问题

    如果cpufreq没有初始化成功,那么CPU的工作频率是多少?

你可能感兴趣的:(linux,运维,服务器)