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

Commit 29d8367c authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Read DDR specific strings for the bus frequency values



Check DDR specific properties for qcom,bus-freq, qcom,bus-min and
qcom,bux-max for each power level and use those if they exist for
the current DDR type otherwise fall back to the default.

Change-Id: Ic0dedbad1a09d5fc5aed7310448acb6519d44bc9
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 8597343a
Loading
Loading
Loading
Loading
+44 −12
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/of.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_device.h>
#include <linux/of_fdt.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/input.h>
#include <linux/io.h>
#include <linux/io.h>
@@ -189,7 +190,7 @@ static inline int adreno_of_read_property(struct device *dev,
	int ret = of_property_read_u32(node, prop, ptr);
	int ret = of_property_read_u32(node, prop, ptr);


	if (ret)
	if (ret)
		dev_err(dev, "Unable to read '%s'\n", prop);
		dev_err(dev, "%pOF: Unable to read '%s'\n", node, prop);
	return ret;
	return ret;
}
}


@@ -887,6 +888,32 @@ static void adreno_of_get_ca_aware_properties(struct adreno_device *adreno_dev,
	}
	}
}
}


static int _of_property_read_ddrtype(struct device_node *node, const char *base,
		u32 *ptr)
{
	char str[32];
	int ddr = of_fdt_get_ddrtype();

	/* of_fdt_get_ddrtype returns error if the DDR type isn't determined */
	if (ddr >= 0) {
		int ret;

		/* Construct expanded string for the DDR type  */
		ret = snprintf(str, sizeof(str), "%s-ddr%d", base, ddr);

		/* WARN_ON() if the array size was too small for the string */
		if (WARN_ON(ret > sizeof(str)))
			return -ENOMEM;

		/* Read the expanded string */
		if (!of_property_read_u32(node, str, ptr))
			return 0;
	}

	/* Read the default string */
	return of_property_read_u32(node, base, ptr);
}

static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev,
static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev,
		struct device_node *node)
		struct device_node *node)
{
{
@@ -917,7 +944,8 @@ static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev,


		if (index >= KGSL_MAX_PWRLEVELS) {
		if (index >= KGSL_MAX_PWRLEVELS) {
			dev_err(device->dev,
			dev_err(device->dev,
				"Pwrlevel index %d is out of range\n", index);
				"%pOF: Pwrlevel index %d is out of range\n",
					child, index);
			continue;
			continue;
		}
		}


@@ -930,23 +958,27 @@ static int adreno_of_parse_pwrlevels(struct adreno_device *adreno_dev,
			&level->gpu_freq))
			&level->gpu_freq))
			return -EINVAL;
			return -EINVAL;


		if (adreno_of_read_property(device->dev, child, "qcom,bus-freq",
		ret = _of_property_read_ddrtype(child,
			&level->bus_freq))
			"qcom,bus-freq", &level->bus_freq);
			return -EINVAL;
		if (ret) {
			dev_err(device->dev,
				"%pOF: Couldn't read the bus frequency for power level %d\n",
				child, index);
			return ret;
		}


		if (of_property_read_u32(child, "qcom,bus-min",
			&level->bus_min))
		level->bus_min = level->bus_freq;
		level->bus_min = level->bus_freq;
		_of_property_read_ddrtype(child,
			"qcom,bus-min", &level->bus_min);


		if (of_property_read_u32(child, "qcom,bus-max",
			&level->bus_max))
		level->bus_max = level->bus_freq;
		level->bus_max = level->bus_freq;
		_of_property_read_ddrtype(child,
			"qcom,bus-max", &level->bus_max);
	}
	}


	return 0;
	return 0;
}
}



static void adreno_of_get_initial_pwrlevel(struct adreno_device *adreno_dev,
static void adreno_of_get_initial_pwrlevel(struct adreno_device *adreno_dev,
		struct device_node *node)
		struct device_node *node)
{
{