Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c43c1a31 authored by Matt Wagantall's avatar Matt Wagantall
Browse files

msm: clock-krait-8974: Expose PVS table data through module parameters



For debugging purposes, it's sometimes useful to retrieve part
PVS and speed bin data at runtime. Export this data via a module
parameters for easy access. Having a static copy of this data also
makes its recovery from a ramdump convenient.

A 'qcom,pvs-config-ver' device-tree property is also introduced.
It will not be used by software, but can be queried to see the
which version of the voltage configuration data is present in
the build.

Change-Id: I233919d8c4970fe4e1263423ab9f08cabcc0986d
Signed-off-by: default avatarMatt Wagantall <mattw@codeaurora.org>
parent c4127fbe
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ Optional properties:
- qcom,hfpll-user-vco-mask:
			The mask to be used when programming the VCO selection
			bits in the user control register.
- qcom,pvs-config-ver:
			The version of the data in qcom,speedX-pvsY-bin-vZ.

Example:
	qcom,clock-krait@f9016000 {
+22 −11
Original line number Diff line number Diff line
@@ -487,7 +487,7 @@ static struct clk *cpu_clk[] = {
};

static void get_krait_bin_format_b(struct platform_device *pdev,
					int *speed, int *pvs, int *ver)
					int *speed, int *pvs, int *pvs_ver)
{
	u32 pte_efuse, redundant_sel;
	struct resource *res;
@@ -495,7 +495,7 @@ static void get_krait_bin_format_b(struct platform_device *pdev,

	*speed = 0;
	*pvs = 0;
	*ver = 0;
	*pvs_ver = 0;

	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "efuse");
	if (!res) {
@@ -516,7 +516,7 @@ static void get_krait_bin_format_b(struct platform_device *pdev,
	*speed = pte_efuse & 0x7;
	/* 4 bits of PVS are in efuse register bits 31, 8-6. */
	*pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
	*ver = (pte_efuse >> 4) & 0x3;
	*pvs_ver = (pte_efuse >> 4) & 0x3;

	switch (redundant_sel) {
	case 1:
@@ -544,7 +544,7 @@ static void get_krait_bin_format_b(struct platform_device *pdev,
		*pvs = 0;
	}

	dev_info(&pdev->dev, "PVS version: %d\n", *ver);
	dev_info(&pdev->dev, "PVS version: %d\n", *pvs_ver);

	devm_iounmap(&pdev->dev, base);
}
@@ -658,12 +658,16 @@ static void krait_update_uv(int *uv, int num, int boost_uv)
	}
}

static char table_name[] = "qcom,speedXX-pvsXX-bin-vXX";
module_param_string(table_name, table_name, sizeof(table_name), S_IRUGO);
static unsigned int pvs_config_ver;
module_param(pvs_config_ver, uint, S_IRUGO);

static int clock_krait_8974_driver_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct clk *c;
	int speed, pvs, ver, rows, cpu;
	char prop_name[] = "qcom,speedXX-pvsXX-bin-vXX";
	int speed, pvs, pvs_ver, config_ver, rows, cpu;
	unsigned long *freq, cur_rate, aux_rate;
	struct resource *res;
	int *uv, *ua;
@@ -747,15 +751,22 @@ static int clock_krait_8974_driver_probe(struct platform_device *pdev)
	if (!ret)
		hdata.user_vco_mask = vco_mask;

	get_krait_bin_format_b(pdev, &speed, &pvs, &ver);
	snprintf(prop_name, ARRAY_SIZE(prop_name),
			"qcom,speed%d-pvs%d-bin-v%d", speed, pvs, ver);
	ret = of_property_read_u32(dev->of_node, "qcom,pvs-config-ver",
			&config_ver);
	if (!ret) {
		pvs_config_ver = config_ver;
		dev_info(&pdev->dev, "PVS config version: %d\n", config_ver);
	}

	get_krait_bin_format_b(pdev, &speed, &pvs, &pvs_ver);
	snprintf(table_name, ARRAY_SIZE(table_name),
			"qcom,speed%d-pvs%d-bin-v%d", speed, pvs, pvs_ver);

	rows = parse_tbl(dev, prop_name, 3,
	rows = parse_tbl(dev, table_name, 3,
			(u32 **) &freq, (u32 **) &uv, (u32 **) &ua);
	if (rows < 0) {
		/* Fall back to most conservative PVS table */
		dev_err(dev, "Unable to load voltage plan %s!\n", prop_name);
		dev_err(dev, "Unable to load voltage plan %s!\n", table_name);
		ret = parse_tbl(dev, "qcom,speed0-pvs0-bin-v0", 3,
				(u32 **) &freq, (u32 **) &uv, (u32 **) &ua);
		if (ret < 0) {