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

Commit da6a98b8 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Allow compatible string matching for gpu devices"

parents f69d3db0 3f65d0a9
Loading
Loading
Loading
Loading
+23 −29
Original line number Diff line number Diff line
@@ -615,7 +615,8 @@ static inline bool _rev_match(unsigned int id, unsigned int entry)
	return (entry == ANY_ID || entry == id);
}

static inline const struct adreno_gpu_core *_get_gpu_core(unsigned int chipid)
static const struct adreno_gpu_core *
_get_gpu_core(struct platform_device *pdev, unsigned int chipid)
{
	unsigned int core = ADRENO_CHIPID_CORE(chipid);
	unsigned int major = ADRENO_CHIPID_MAJOR(chipid);
@@ -623,6 +624,15 @@ static inline const struct adreno_gpu_core *_get_gpu_core(unsigned int chipid)
	unsigned int patchid = ADRENO_CHIPID_PATCH(chipid);
	int i;

	/* Check to see if any of the entries match on a compatible string */
	for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
		if (adreno_gpulist[i]->compatible &&
			of_device_is_compatible(pdev->dev.of_node,
				adreno_gpulist[i]->compatible))
			return adreno_gpulist[i];
	}


	for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) {
		if (core == adreno_gpulist[i]->core &&
		    _rev_match(major, adreno_gpulist[i]->major) &&
@@ -718,16 +728,16 @@ adreno_update_soc_hw_revision_quirks(struct adreno_device *adreno_dev,
		of_node_put(node);
}

static int adreno_identify_gpu(struct adreno_device *adreno_dev)
static int adreno_identify_gpu(struct platform_device *pdev,
		struct adreno_device *adreno_dev)
{
	struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
	struct adreno_gpudev *gpudev;
	int i;

	adreno_dev->gpucore = _get_gpu_core(adreno_dev->chipid);
	adreno_dev->gpucore = _get_gpu_core(pdev, adreno_dev->chipid);

	if (adreno_dev->gpucore == NULL) {
		dev_crit(&device->pdev->dev,
		dev_crit(&pdev->dev,
			"Unknown GPU chip ID %8.8X\n", adreno_dev->chipid);
		return -ENODEV;
	}
@@ -737,7 +747,7 @@ static int adreno_identify_gpu(struct adreno_device *adreno_dev)
	 * message
	 */
	if (adreno_dev->gpucore->features & ADRENO_DEPRECATED) {
		dev_err(&device->pdev->dev,
		dev_err(&pdev->dev,
			"Support for GPU %d.%d.%d.%d has been deprecated\n",
			adreno_dev->gpucore->core,
			adreno_dev->gpucore->major,
@@ -764,18 +774,13 @@ static int adreno_identify_gpu(struct adreno_device *adreno_dev)
	return 0;
}

static const struct platform_device_id adreno_id_table[] = {
	{ "kgsl-3d0", (unsigned long) &device_3d0, },
	{},
};

MODULE_DEVICE_TABLE(platform, adreno_id_table);

static const struct of_device_id adreno_match_table[] = {
	{ .compatible = "qcom,kgsl-3d0", .data = &device_3d0 },
	{}
	{ },
};

MODULE_DEVICE_TABLE(of, adreno_match_table);

/* Dynamically build the OPP table for the GPU device */
static void adreno_build_opp_table(struct device *dev, struct kgsl_pwrctrl *pwr)
{
@@ -1311,18 +1316,13 @@ static void adreno_setup_device(struct adreno_device *adreno_dev)
static int adreno_bind(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	const struct of_device_id *of_id;
	struct adreno_device *adreno_dev;
	struct kgsl_device *device;
	int status;
	unsigned int priv = 0;
	u32 size, hwrev;

	of_id = of_match_device(adreno_match_table, &pdev->dev);
	if (!of_id)
		return -EINVAL;

	adreno_dev = (struct adreno_device *) of_id->data;
	adreno_dev = (struct adreno_device *) of_device_get_match_data(dev);

	/* Initialize the adreno device structure */
	adreno_setup_device(adreno_dev);
@@ -1350,7 +1350,7 @@ static int adreno_bind(struct device *dev)
	device->speed_bin = status;

	/* Get the chip ID from the DT and set up target specific parameters */
	if (adreno_identify_gpu(adreno_dev))
	if (adreno_identify_gpu(pdev, adreno_dev))
		return -ENODEV;

	status = adreno_of_get_power(adreno_dev, pdev);
@@ -1499,17 +1499,12 @@ static void _adreno_free_memories(struct adreno_device *adreno_dev)

static void adreno_unbind(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	const struct of_device_id *of_id;
	struct adreno_device *adreno_dev;
	struct kgsl_device *device;
	struct adreno_gpudev *gpudev;

	of_id = of_match_device(adreno_match_table, &pdev->dev);
	if (!of_id)
		return;
	adreno_dev = (struct adreno_device *) of_device_get_match_data(dev);

	adreno_dev = (struct adreno_device *) of_id->data;
	device = KGSL_DEVICE(adreno_dev);
	gpudev = ADRENO_GPU_DEVICE(adreno_dev);

@@ -3781,11 +3776,10 @@ static const struct dev_pm_ops adreno_pm_ops = {
static struct platform_driver adreno_platform_driver = {
	.probe = adreno_probe,
	.remove = adreno_remove,
	.id_table = adreno_id_table,
	.driver = {
		.name = "kgsl-3d",
		.pm = &adreno_pm_ops,
		.of_match_table = adreno_match_table,
		.of_match_table = of_match_ptr(adreno_match_table),
	}
};

+5 −0
Original line number Diff line number Diff line
@@ -340,6 +340,11 @@ struct adreno_reglist {
struct adreno_gpu_core {
	enum adreno_gpurev gpurev;
	unsigned int core, major, minor, patchid;
	/**
	 * @compatible: If specified, use the compatible string to match the
	 * device
	 */
	const char *compatible;
	unsigned long features;
	struct adreno_gpudev *gpudev;
	unsigned long gmem_base;