diff mbox

[2/9] drm/msm: Drop the gpu binding

Message ID 1462273081-5814-3-git-send-email-architt@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Archit Taneja May 3, 2016, 10:57 a.m. UTC
The driver currently identifies the GPU components it needs by parsing
a phandle list from the 'gpus' DT property.

This isn't the right binding to go with. So, for now, just search all
device nodes and find the gpu node we need by parsing a list of
compatible strings.

Once we know how to link the kms and gpu drivers, we'll drop this method
and use the correct binding.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
 drivers/gpu/drm/msm/msm_drv.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Comments

Rob Herring (Arm) May 3, 2016, 12:42 p.m. UTC | #1
On Tue, May 3, 2016 at 5:57 AM, Archit Taneja <architt@codeaurora.org> wrote:
> The driver currently identifies the GPU components it needs by parsing
> a phandle list from the 'gpus' DT property.
>
> This isn't the right binding to go with. So, for now, just search all
> device nodes and find the gpu node we need by parsing a list of
> compatible strings.
>
> Once we know how to link the kms and gpu drivers, we'll drop this method
> and use the correct binding.
>
> Signed-off-by: Archit Taneja <architt@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/msm_drv.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 30b8f3b..f717a69 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -1068,20 +1068,32 @@ static int compare_of(struct device *dev, void *data)
>         return dev->of_node == data;
>  }
>
> -static int add_components(struct device *dev, struct component_match **matchptr,
> -               const char *name)
> +static const char * const msm_compatible_gpus[] = {
> +       "qcom,adreno-3xx",
> +       "qcom,kgsl-3d0",
> +};
> +
> +/*
> + * We don't know what's the best binding to link the gpu with the drm device.
> + * Fow now, we just hunt for all the possible gpus that we support, and add them
> + * as components.
> + */
> +static int add_gpu_components(struct device *dev,
> +                             struct component_match **matchptr)
>  {
> -       struct device_node *np = dev->of_node;
>         unsigned i;
>
> -       for (i = 0; ; i++) {
> +       for (i = 0; i < ARRAY_SIZE(msm_compatible_gpus); i++) {

You can use of_find_matching_node() here instead of a loop.

Rob
Archit Taneja May 4, 2016, 6:45 a.m. UTC | #2
On 05/03/2016 06:12 PM, Rob Herring wrote:
> On Tue, May 3, 2016 at 5:57 AM, Archit Taneja <architt@codeaurora.org> wrote:
>> The driver currently identifies the GPU components it needs by parsing
>> a phandle list from the 'gpus' DT property.
>>
>> This isn't the right binding to go with. So, for now, just search all
>> device nodes and find the gpu node we need by parsing a list of
>> compatible strings.
>>
>> Once we know how to link the kms and gpu drivers, we'll drop this method
>> and use the correct binding.
>>
>> Signed-off-by: Archit Taneja <architt@codeaurora.org>
>> ---
>>   drivers/gpu/drm/msm/msm_drv.c | 26 +++++++++++++++++++-------
>>   1 file changed, 19 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
>> index 30b8f3b..f717a69 100644
>> --- a/drivers/gpu/drm/msm/msm_drv.c
>> +++ b/drivers/gpu/drm/msm/msm_drv.c
>> @@ -1068,20 +1068,32 @@ static int compare_of(struct device *dev, void *data)
>>          return dev->of_node == data;
>>   }
>>
>> -static int add_components(struct device *dev, struct component_match **matchptr,
>> -               const char *name)
>> +static const char * const msm_compatible_gpus[] = {
>> +       "qcom,adreno-3xx",
>> +       "qcom,kgsl-3d0",
>> +};
>> +
>> +/*
>> + * We don't know what's the best binding to link the gpu with the drm device.
>> + * Fow now, we just hunt for all the possible gpus that we support, and add them
>> + * as components.
>> + */
>> +static int add_gpu_components(struct device *dev,
>> +                             struct component_match **matchptr)
>>   {
>> -       struct device_node *np = dev->of_node;
>>          unsigned i;
>>
>> -       for (i = 0; ; i++) {
>> +       for (i = 0; i < ARRAY_SIZE(msm_compatible_gpus); i++) {
>
> You can use of_find_matching_node() here instead of a loop.

I'll switch to that.

Thanks,
Archit
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 30b8f3b..f717a69 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1068,20 +1068,32 @@  static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
-static int add_components(struct device *dev, struct component_match **matchptr,
-		const char *name)
+static const char * const msm_compatible_gpus[] = {
+	"qcom,adreno-3xx",
+	"qcom,kgsl-3d0",
+};
+
+/*
+ * We don't know what's the best binding to link the gpu with the drm device.
+ * Fow now, we just hunt for all the possible gpus that we support, and add them
+ * as components.
+ */
+static int add_gpu_components(struct device *dev,
+			      struct component_match **matchptr)
 {
-	struct device_node *np = dev->of_node;
 	unsigned i;
 
-	for (i = 0; ; i++) {
+	for (i = 0; i < ARRAY_SIZE(msm_compatible_gpus); i++) {
 		struct device_node *node;
 
-		node = of_parse_phandle(np, name, i);
+		node = of_find_compatible_node(NULL, NULL,
+					       msm_compatible_gpus[i]);
 		if (!node)
-			break;
+			continue;
 
 		component_match_add(dev, matchptr, compare_of, node);
+
+		of_node_put(node);
 	}
 
 	return 0;
@@ -1163,7 +1175,7 @@  static int msm_pdev_probe(struct platform_device *pdev)
 	struct component_match *match = NULL;
 
 	add_mdss_components(&pdev->dev, &match);
-	add_components(&pdev->dev, &match, "gpus");
+	add_gpu_components(&pdev->dev, &match);
 
 	pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
 	return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);