diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index cd37ab764648..388198f24f84 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -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, @@ -1340,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); diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index f1cda8da3c56..82fd5095470a 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -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;